Qt on Apple Silicon
When Apple announced the macOS transition to arm64 last year with their new Apple Silicon M1 chip, we immediately started prototyping native support in Qt — initially on developer transition kits (DTK), and later on production hardware once that became available. The Rosetta translation layer already took care of running existing Qt applications on Apple Silicon, but we wanted native arm64 builds, to squeeze out all the power from this new chipset.
Luckily for us, Qt already had good cross compilation support, as well as arm64 support thanks to our iOS port, so bringing Qt up on Apple Silicon didn't initially take too much effort. The devil was in the details though.
One major hurdle was convincing the build system to not only treat arm64 as a supported configuration on macOS, but to allow building Qt for both x86_64 and arm64 in one go, producing so called universal builds.
Another was ensuing that all our third party dependencies such as Chromium, PCRE, and OpenSSL were available and updated with arm64-support.
And, last but not least, we needed to add arm64 macOS into our CI so we could run all the tests, which due to lack of virtualization options required some rethinking and additional work.
I'm happy to say that these issues have been resolved, and Qt on Apple Silicon support is scheduled for the upcoming Qt 6.2 release. This includes both cross compiling to arm64, as well as developing Qt applications on Apple Silicon.
Trying it out
You can try out Qt on Apple Silicon already now by installing the 6.2 preview from the Qt installer. The Qt SDK is fully universal, and should run on both Intel and Apple Silicon hardware.
You can also check out the 6.2 branch of the Qt repositories and build Qt from source. By default, Qt will be built for your local architecture, i.e. x86_64 if you're on an Intel Mac, and arm64 if you're on an Apple Silicon Mac. To produce a universal build, add the following argument to configure:
./configure <other options> -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
Once you have a Qt build for Apple Silicon your can use CMake like normal to configure and build your application. CMake also defaults to building for your local architecture, so to produce a universal build of your application, add the same argument when configuring:
cmake ~/src/myapp -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
Note that if you have third party dependencies these must be built as universal binaries as well.
For more details about building Qt applications for Apple Silicon see the documentation.
Building and debugging in Qt Creator
As Qt Creator is still 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.
Note: to attach a debugger you will need an x86_64 build of your application.
These issues will be fixed before the final 6.2 release. Please let us know if you find other issues.
What about Qt 5?
Our initial focus was on getting Qt for Apple Silicon into shape for Qt 6, but once 6.2 is out we'll take a look at the Qt 5.15 commercial LTS, and how we can improve the situation there as well.
Some patches already went into Qt 5, so Qt 5.15.4 and above should build and run by passing -device-option QMAKE_APPLE_DEVICE_ARCHS=arm64 to configure. Note that this configuration is not tested in CI, and is hence unsupported at this point.
Applications built for x86_64 will run through the Rosetta translation layer, which should in most cases work fine. We are aware of a few bugs there, but please do not hesitate to file more if you find any issues 😊
Subscribe to our newsletter
Try Qt 6.5 Now!
Download the latest release here: www.qt.io/download.
Qt 6.5 is the latest Long-Term-Support release with all you need for C++ cross-platform app development.
Qt World Summit 2023: Berlin awaits!
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.