How to build Qt6 from source for arm and intel on macOS
-
Hi,
I've just moved to an Apple M2 and I'm trying to build Qt from source for both Intel and ARM. (I've previously built Qt successfully for Intel on my Intel mac.)
Qt's documentation on
https://doc.qt.io/qt-6/macos-building.html
says to use./configure -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64"
and I add the prefix option, giving
./configure -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64" -prefix /Users/<myname>/Qt/6.4.3_fixed
This doesn't work. The build process complains about an extra path - presumably due to the '--'.
However, if I use
./configure -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64" -prefix /Users/<myname>/Qt/6.4.3_fixed
(and
cmake –build . –parallel
cmake –install .
)the build works but the installed directory is about half the size of the precompiled macOS download from the Qt Maintenance app. This suggests to me that the precompiled binaries support both ARM and Intel, but that my build does not.
Any help would be most appreciated. (I'm trying to move to universal binaries and there are a few things I regularly need to patch in Qt, hence building myself.)
Michael
-
Hi,
I've just moved to an Apple M2 and I'm trying to build Qt from source for both Intel and ARM. (I've previously built Qt successfully for Intel on my Intel mac.)
Qt's documentation on
https://doc.qt.io/qt-6/macos-building.html
says to use./configure -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64"
and I add the prefix option, giving
./configure -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64" -prefix /Users/<myname>/Qt/6.4.3_fixed
This doesn't work. The build process complains about an extra path - presumably due to the '--'.
However, if I use
./configure -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64" -prefix /Users/<myname>/Qt/6.4.3_fixed
(and
cmake –build . –parallel
cmake –install .
)the build works but the installed directory is about half the size of the precompiled macOS download from the Qt Maintenance app. This suggests to me that the precompiled binaries support both ARM and Intel, but that my build does not.
Any help would be most appreciated. (I'm trying to move to universal binaries and there are a few things I regularly need to patch in Qt, hence building myself.)
Michael
Hi,
Run ˋlipo -info` on one of the library to check which architectures you have. The size might not play a role depending on the options you used with the installer such as installing the debug symbols.
-
Thanks. I've since found that my successful build - above - is defaulting to intel and is ignoring arm64. if I reorder the configure command to:
./configure -prefix /Users/<myname>/Qt/6.4.3_fixed -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64"
the configure command completes successfully. However the build
cmake –build . –parallel
fails to link qtbase/lib/QtGui.framework/Versions/A/QtGui and gives a bunch of "Undefined symbols for architecture arm64" errors relating to support for Neon.
-
Thanks. I've since found that my successful build - above - is defaulting to intel and is ignoring arm64. if I reorder the configure command to:
./configure -prefix /Users/<myname>/Qt/6.4.3_fixed -- -DCMAKE_OSX_ARCHITECTURES="x86_64h;arm64"
the configure command completes successfully. However the build
cmake –build . –parallel
fails to link qtbase/lib/QtGui.framework/Versions/A/QtGui and gives a bunch of "Undefined symbols for architecture arm64" errors relating to support for Neon.
Which errors are you getting exactly ?
-
I raised this as a bug report with Qt. They have reproduced the problem when using "x86_64h;arm64" and they are still looking into it.
Dropping the 'h', and therefore using "x86_64;arm64", works fine.
-
Good to know, thanks !
Can you share the link of your report ?
-