views:

1285

answers:

3

I need to build my QT console application as 64 bit. i.e. x86_64

My config file looks like this:

CONFIG += qt console debug x86_64
CONFIG -= app_bundle

HEADERS = HelperClass.h
SOURCES = HelperClass.cpp \
            main.cpp

The compile goes fine without issue. But, when the build gets to the link step, it complains that I don't have the Qt x86_64 architecture.

Excerpt from build:

ld: warning in /Library/Frameworks/QtGui.framework/QtGui, missing required architecture x86_64 in file
ld: warning in /Library/Frameworks/QtCore.framework/QtCore, missing required architecture x86_64 in file
Undefined symbols:
  "QIODevice::getChar(char*)", referenced from:
...

Do I need to download the Qt source and build the required architecture for this to work? My install is from the provided binaries for Mac OSX - Qt 4.5.2 on the QT site. I'm guessing that build does not come with 64bit versions of the libraries. Am I correct?

A: 

From the Qt for Open Source C++ development on Mac OS X page it appears that the 32 and 64 bit libraries should be included:

Mac binary package using Cocoa for Mac OS X 10.5 (32-bit and 64-bit) http://get.qtsoftware.com/qt/source/qt-mac-cocoa-opensource-4.5.2.dmg

If you are still having trouble you could try to download the source from the same page:

http://get.qtsoftware.com/qt/source/qt-mac-opensource-src-4.5.2.tar.gz

and configure with:

-arch x86_64

See http://doc.trolltech.com/4.5/developing-on-mac.html#universal-binaries

Note that the link above mentions that if no arch is specified it builds 32bit for the current platform.

Jesse
A: 

You can check the libraries using "file":

$ file /Library/Frameworks/QtGui.framework/QtGui /Library/Frameworks/QtGui.framework/QtGui: Mach-O universal binary with 4 architectures /Library/Frameworks/QtGui.framework/QtGui (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64 /Library/Frameworks/QtGui.framework/QtGui (for architecture ppc7400): Mach-O dynamically linked shared library ppc /Library/Frameworks/QtGui.framework/QtGui (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 /Library/Frameworks/QtGui.framework/QtGui (for architecture i386): Mach-O dynamically linked shared library i386

I see the same "ld warning: ... missing required architecture x86_64 in file" errors, so the error message is misleading.

George White
+1  A: 

The QT SDK does NOT include by default the 64 bit libraries in Mac OS X (I think it is strange but it is that way). For compiling my apps in x86_64 I just download the standalone libraries with Cocoa (32/64 bits) and I install them after the SDK is installed.

Everything works like a charm then.

Josep