In part 2, I attempted to install the win32 version of the Qt Framework on Linux without using windows. I failed.

Can we get Qt for mac without a mac ?

I did download the installer. It’s a .dmg. It would be an issue, but with the power of darling we can mount DMGs on Linux. No problem at all. It’s the kind of things we do here.

But mounting the Qt installer dmg reveals that it contain a binary and a .dat file rather than a simple folder or something manageable.

Presumably, the binary is the installer. Maybe it runs on darling ? No. Hard dependency on the OpenGL framework.

Great software bundled in crappy unusable packages seems to be a recurring theme.

Is all hope lost again ? Not this time.

We can build Qt for mac, like we attempted for Windows. But it will work. Mac has make . It knows about clang and gcc, it’s very much like Linux in a lot of aspects. There is an UNIX under there after all ( But I always had the feeling that OSX internals are terrible, hidden under a nice user interface. For starter, a large number of tools haven’t been maintained after their upstream version moved to GPLv3, 10 years ago ).

Alas, it means dealing with Qt’s complex build system. It took some time to hack the qmake build files. See, Qt makes the terrible assumption that all toolchain on osx involve xcode. We don’t have xcode.

But once you bypass all the automatic probes and assumptions about what’s installed on the system….

….you can get it to work !

#configure -release -opensource -confirm-license -xplatform macx-cross-clang -skip qtwebengine -nomake examples -nomake tests -prefix /home/cor3ntin/dev/cross-compilers/osx/qt5_10

Output of configure. I removed some irrelevant lines.

It was not quite the end of the road. Qt Widgets failed to build because of missing dependencies. QtLocation failed to build because the libc++ headers were too old or broken ( I fixed that by copying the latest libc++ version within the OSX SDK. It worked). Then QtLocation complained because std::auto_ptr was not defined so I hacked a few headers.

I tried to get qwebengine (chromium ) to build, but it uses another build system still, and I had done enough build system hacking for one night.

But in the end most of Qt did build.

It took me a few hours but I got Qt !

And what we have then, is something quite interesting. The binaries are natives Linux ELF, while the frameworks and libraries are Macho-O. That will be handy in a minute.

Hello, I’m a Mac — And I’m a PC. And I am a Mac too. — What ?

Qt is a big piece of software making full use of the underlying system capabilities, in term of OS integration. If we can build that, we can build almost anything.

I initially called my mkspec file darling-clang . I was a bad name. it also prevented qbs to understand that it was a mac build. Rather than renaming the mkspec and rebuilding Qt, I modified qbs. the code of qbs-setup-qt is actually parsing the mkspec’s .conf files with regular expressions. Somehow, it works. Just don’t breathe on it.

Eventually, once I gave qbs what it expected to understand that we were dealing with mac, I was able to call

qbs-setup-qt osx/qt5_10/bin/qmake osx-x64-qt510

Which created the right profiles and modules. I cleaned up my profiles manually to merge clang-osx and osx-x64-qt510

And then we can compile or magnificent Hello World app !

Compiling an OSX application based on Qt on Linux, using qbs : check

What now ?

Well, we have a complete toolchain, maybe we can check some things ?

Using otool -L , the osx equivalent of ldd we can assert that we indeed link to some libraries