I am trying to port a linux project to macOS. However I can't even setup the build environment on an M1 Macbook Air 2020 (Apple silicon). I installed qt-creator, cmake, qt 5.15 and 6.1 using homebrew. I added the qt versions and cmake in the qt-creator settings. When I want to put everything together in the kits tab, I get the error in the title.
Checking the compilers tab, I realized that the autodetected clang compilers are x86 only. So I cloned the x86 clang++ entry and changed the ABI from x64 to arm. This should work I though, since clang++ is a unversial binary as file /usr/bin/clang++ reports
/usr/bin/clang++: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/clang++ (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/clang++ (for architecture arm64e): Mach-O 64-bit executable arm64e
What do I have to do to make Qt Creator able to build universal binaries? Or at least any build at all?
You need to install Qt 6.2 version which brings support for macOS on Apple Silicon. Porting tasks were tracked under this bug report. Currently, Qt5 doesn't support building for M1 chip.
In addition to updating to Qt6.2 you also need to update your Qt Creator version to Qt Creator 6. Alternatively, you can try the build flags below with Qt Creator 5.
As Qt Creator 5 is built as a non-universal binary, it will default to producing x86_64 binaries, regardless of which architecture your machine is. To build for arm64, add -DCMAKE_OSX_ARCHITECTURES=arm64 explicitly to the "Initial CMake parameters" of the project build settings, or QMAKE_APPLE_DEVICE_ARCHS=arm64 to the qmake "Additional arguments" field.
Related
I have 16" M1 Pro MacBook Pro. The third party C library (.a) was built with Intel Mac and there's absolutely no way to modify the code or rebuild with M1 Mac. The binary is x64 binary.
My project is using C++ and Objective-C++ (.mm) with Xcode. It is targeted for Mac app and not iOS. I want to link the C library to my project.
The linked library 'libkfunc64.a' is missing one or more architectures
required by this target: arm64.
I checked similar question but it didn't work:
Can Xcode on m1 Mac build targeting Intel
What I want to do is to generate an Intel binary. I don't need a M1 binary or hybrid binary - I can run Intel binary on Rosetta 2 on M1 Mac.
I created a console-app with "-arch x86_64" option for LLVM C++ compiler and it worked. But I don't know how to pass that option on Xcode.
Please tell me how to do it. I am using Xcode 13.3.
Xcode - Targets - Build Settings
Architectures (x86_64) or Excluded Architectures(arm64).
I've only tested the opposite.
Arm64 required, no x86_64.
I am using Qt 5.15.2 on my Mac mini with M1 chip. This works fine (due to Rosetta). Below is the list of compilers Qt Creator found on this computer, and among them is the C++, x86 64bit that I use. No problem.
I would like to use the same settings on a (somewhat newer) Mac Book Pro (also with M1 chip). Below is the list of compilers Qt Creator finds on this computer, the x86 is now missing!
I do not know if I have a x86 compiler on the new M1-computer. I have installed Xcode and the command line tools for XCode 13.2.
Can I somewhere tell Qt Creator that the deployment target is x86?
Does /usr/bin/clang++ only compile for the ARM/M1-chip, or can it also produce and link to x86 code?
if not, how can I find out if there is an x86 compiler on my new M1-computer?
If the compiler is missing, how to install it?
Any help would be most appreciated!
A few tips that can help, I just setup a project using Qt 5.15.2 on a 2021 M1 Mac.
Note this will likely be different for Qt >= 6.
Can I somewhere tell Qt Creator that the deployment target is x86?
Yes, you can do this using specific argument in the build settings of your kit.
Add the QMAKE_APPLE_DEVICE_ARCHS="x86_64" additional argument to qmake.
Also, add an additional CMake option: -DCMAKE_OSX_ARCHITECTURES:STRING="x86_64"
ℹ️ Click Manage Kits.. in the projects view to open the preferences editor where you can update your CMake configuration.
Does /usr/bin/clang++ only compile for the ARM/M1-chip, or can it also produce and link to x86 code?
With rosetta installed (/usr/sbin/softwareupdate –install-rosetta –agree-to-license), and the configuration above, yes you can compile and link x86 binaries.
I have recently updated Qt to v 5.12.0. This version includes MinGW 7.3 W64 and there is not option to download MinGW 7.3 W32 as in previous version of Qt (see image below).
I've built my application using QtCreator 4.8.1, and it was built without issues, however I noticed that my binary file is in 64 bits, and not in 32 bits like in previous version of Qt.
My problem is that I want to build my application for x86 platforms, but I can't find any options in Qt to do that. How can I cross compile my app for x86 using MinGW 7.3 w64 and QtCreator?
FYI: My OS is Windows 10 x64.
It is possible to download the 32-bit version of mingw-64 separately
sourceforge.net
After that you should configure your Qt Kits in Qt Creator.
Good day all
I have been searching for a method of cross-compiling for QT-Creator in Linux for sometime now, and I have been having alot of trouble with it.
Background info
please note: I am on a Linux machine, and would like to cross compile Windows Apps
My system:
Ubuntu Gnome 16.10
QT Creator 4.0.2 (based on QT 5.7)
I have came across a few SO links, a few blogs with broken instructions, etc and one seeming helpful but dependencies could not be found.
I have also attempted another compiler MXE and cloned and attempted to build the MXE compiler from the GIT repo, which failed (no solution for the build error - VTK build error)
I decided to download precompiled MinGW compilers (i686 and x86_x64 versions) from sourceforge
Issue:
In QT Creator, adding the compiler is done without an issue, adding the "Kit" and selecting the newly added compiler, an red exclamation gives an error
The Compiler (x86_windows_msys_pe_64bit) cannot produce code for QT version 5.7.0 GCC 64Bit (x86_linux_generic_elf_64bit)
This occurs for both 32 + 64 bit compilers.
I think that you should have a QT version that matches your compiler ABI. The error tells you that the MinGW compiler doesn't match the Linux version of QT you have used. Therefore, get a windows version of QT and use it instead (just as you've added WinGW).
You can download Qt Binaries from here.
I downloaded OpenCV 2.4.13 release from GitHub. Then I configured CMake project using CMake-gui for android.
There is variable called ANDROID_ABI and I can select value for it using drop-down list. But in this list I can chose only armeabi, armeabi-v6 with VFP, armeabi-v7a, armeabi-v7a with NEON, armeabi-v7a with VFPV3.
I can use CMake console for configure and generate project for arm64 or I can modify cmake scripts and list it manually. But when I try to build generated project, I get error unknown type name '__uint128_t'__uint128_t. So I think there are reasons why I can't select this variant from drop-down list.
How can I chose arm64 variant for build and why I get such kind of error?
It seems that your toolchain, has no armv8 64 bit option.
However there is an new opencv 3.0 release, and probably your uint errors will be fixed:
http://opencv.org/downloads.html
If your toolchain doesn't support 64 bits, you can make your own toolchain for arm64.
$NDK/build/tools/make-standalone-toolchain.sh \
--arch=arm --platform=android-21 --install-dir=/tmp/my-android-toolchain
https://developer.android.com/ndk/guides/standalone_toolchain.html?hl=es
Don't forget to put android_native_level in 21 (android 5.0.1) on cmake android options, because 64 bit support is done on devices which have android 5 or higher.