Cross compile Qt from Linux to Macos
-
Hi everyone!
In our company we need to compile .app from Linux to Macos. And for now I just searched the internet about actual topics, and found only ones from 5 or more year older. Does anybody know any fresh solution for this?
Documentation tells me, that while building Qt from source, I have to specify flat -xplatform and tell it for example "macx-clang". But it always says me an error during build that "Failed to process makespec for platform "macx-clang". Project ERROR: Could not resolve SDK Path for "macosx"."
I already get from the other projects some macos tools, such as otool, af, and others, and set some parameters in the configuration files for ./configure script. But this error comes from this variable "QMAKE_MAC_SDK = macosx", and in the script further it goes to /usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK. And in Linux no such tool as xcodebuild, does it means that I can't build Qt from Lunux for Macos?
I also notices, that some old projects tells you to migrate xcode tools from mac to linux, and pack them in specific way, which i failed also, but anyways It doesn't tells you to specify this QMAKE_MAC_SDK.
Do you have any suggestions, how to fix any of my troubles or do it from scratch?
-
@IsAnton said in Cross compile Qt from Linux to Macos:
And in Linux no such tool as xcodebuild, does it means that I can't build Qt from Lunux for Macos?
Yes, Apple is the odd one out. You need a Mac to compile for iOS and/or MacOS. As far as I know, no way around it.
-
Hi,
@IsAnton said in Cross compile Qt from Linux to Macos:
@J.Hilk But 5 to 7 years ago people told, that they could build Qt at that time with target macos. Did It become impossible after that?
Did they talk about cross-compiling Qt form Linux to macOS ?
It's highly unlikely, Apple never provided any way to cross-compile anything to its platform. To the best of my knowledge, Qt is no exception and never was cross-compiled from Linux to macOS.
-
@SGaist I believe yes, they did!
This one for example https://dexp.in/articles/qtcreator-crosscompile/ .
They built Qt from source for sure :
./configure -xplatform macx-x-g++ ...... - from Linux, it was written in 2013. What do you think about this? -
That it's resource I didn't know about, so thank you.
On the darker side of things: it's about 7 years old. In between Apple has moved to 100% Clang, macOS is at 10.14 and Xcode 10.
You may succeed but you'll have to work you way through it.
Also note that it was never officially supported so there may be dragons.
One last thing that comes to mind, macOS is now 100% 64bit so don't lose time trying to build a 32bit executable for it.
-
Hello, I know this is a little old but i found out these and test it.
using this toolchain
combined with this sks
and 3 hours of compiling, you have clang build and ready to use. Just pay attention that the Sdks seems to work from 10.9 to 10.13, the other ones throws errors telling that the c++ folder was not found. This limits us to use c++ 17 and not 20. The binaries of Qt can be found on the PyQT Pip page, there you can find binaries windows, linux and macos. But It would be awesome if QT provides just a Tar.gz or zip with these binaries, It was a pain to find. I hope it helped