[Qt-interest] Qt SDK 4.6 on OS X 10.6: Compile 64bit possible?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Mon Dec 7 17:47:27 CET 2009
Hi,
first off all, yesterday I succeeded in compiling my first application (actually only part of it, a shared library aka "dynlib") on my new Mac OS X, yay! :)
But I had a few obstacles: my first basic question (before I come up with new ones): Is it possible to build 64 bit applications when using the pre-compiled Qt SDK based on Qt 4.6 (the latest one) (on Mac OS 10.6, for that matter)? Does it provide support for both 32 and 64 bit apps? I could not find anything on the web which would confirm that so far.
This is my scenario:
* I installed qt-sdk-mac-opensource-2009.05.dmg
* I installed exiv2 by using "MacPorts"
%> sudo port install exiv2
(during this process exiv2 got compiled)
* I compiled my library code, but at link time I got an error:
"exiv2.dynlib: Incompatible architecture" or something like this
After some research I found out about "universal binaries", 32bit vs 64bit etc., and I quickly figured out that since on Mac OS 10.6 the gcc now generates 64 bit by default (I also studied http://labs.trolltech.com/blogs/2009/08/31/qt-46-on-mac-os-106/) that I had to build my app also 64bit, so I added
CONFIG += x86_64
CONFIG -= x86 ppc // just to make sure I don't get a "universal binary"
But when recompiling I instantly got a "You try to compile a 64bit application, but Qt was built in 32bit" (or something like that) - an #error triggered by some Qt header.
(By the way I did all this using *.pro files and qmake/make, as well as using Qt Creator)
I tried to search for some switches in Qt Creator, as to switch between 32/64 bit, but the only thing I saw a "Project" entry where one can handle different Qt versions (I did not touch these settings however: I left it as it was, "Qt in path" or something).
So when looking at the Qt binary releases (excluding the Qt Creator part: http://qt.nokia.com/downloads/mac-os-cpp) I noticed the choice between Carbon (32 bit only) and Cocoa (apparently "32" and "64" bit).
So I downloaded the "Cocoa" version and simply installed it "over the existing Qt SDK". And et voila, that solved my problem! I can compile with X86_64 and succesfully link with the exiv2.dynlib!
But why is the Qt SDK download above so huge then (doesn't it contain both Qt frameworks for 32bit and 64bit)? And why does the "About" box of Qt Creator still say "based on Qt 4.6, 32 bit"? (And why does it still run then in 32 bit?) Does the "Cocoa" binary really provide two distinct Qt "frameworks", one for 32bit and one for 64bit? Or do I still have a "shadow Qt framework" lying around now on my Mac (the one from the SDK)? Am a bit confused with all this bit-ness... ;)
(Sorry, but I am totally unfamiliar with Mac "Frameworks" as of now - I just know that and where they exist)
And off course the above setting is not the whole truth: before I had the Qt SDK based on 4.5.3 installed (also pre-built), and I set the QMAKESPEC environment to g++-4.2, as to get Makefiles by default (and not XCode projects). I remember at one stage I had BOTH -arch X86 -arch X86_64 flags set (and hence still got the "Incompatible architecture" linker error, even after having installed "Carbon Qt 4.6"!), even though I had CONFIG -= X86 in my *.pro file! I am only mentioning this because obviously the "Qt uninstall.py" script did not a 100% job, it left some files still there. And I think those interfered with my Qt 4.6 installation (e.g. apparently the g++-4.2 makespec has become obsolete in Qt 4.6, but it was still there - after manually removing all mkspecs directories and re-installing Qt 4.6 "Cocoa" only then did the x86_64 flag properly work!)
Uh well, all a bit confusing, but since I got a running configuration I don't care too much. I just found it strange that the latest Qt SDK obviously can't produce 64bit apps (or I just messed up with the installation!). But maybe someone can prove me wrong :) But maybe other bloody Mac beginners will stumble over the same issues and find this posting helpful :)
Summary:
On Mac OS 10.6
* I installed the pre-built Qt SDK + Creator, based on Qt 4.6
* I installed the pre-built Qt "Cocoa" library over the previous installation
* I linked successfully against exiv2 (as built by "MacPorts"), using CONFIG += x86_64
(not sure whether the CONFIG -= x86 ppc is still needed, I stopped experimenting at this point)
Thanks, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list