PDA

View Full Version : Building on MacOSX



Brit
28th March 2012, 20:36
I'm having trouble building a QT application on Mac OSX.

When I compile my application, I get down to the linking section and get a bunch of errors. I tried looking up similar errors online, and it looks like a mismatch between the platform I'm building for and the platform the libraries were compiled on. Unfortunately, I don't know how to fix it. I tried compiling the application for different platforms (i386, ppc, x86_64) using both Debug and Release configurations, but it doesn't seem to make any difference. Do I need to link to something other than the frameworks? I get errors for every Qt framework that I'm linking to.

My system: Running Mac OSX 10.6.8, Intel Core Duo (64-bit processor), XCode 3.2.4. I'm running the most recent version of Qt - i.e. 4.8 (downloaded it this week)

The errors involve linking to the frameworks -
Link ...
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtNetwork.framework/QtNetwork, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtWebKit.framework/QtWebKit, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/phonon.framework/phonon, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtXml.framework/QtXml, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtOpenGL.framework/QtOpenGL, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtGui.framework/QtGui, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/QtCore.framework/QtCore, file was built for unsupported file format which is not the architecture being linked (i386)

I've also tried using the frameworks in:
"/Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/" instead of
"/Users/Brit/Develop/Qt-4.8/Desktop/Qt/474/gcc/lib/"

A few places said that they could solve a similar linking problem (with libs) by rebuilding them, though that seems like a lot of work, and I don't know why this shouldn't work out of the box since I'm not doing anything too complicated.

ChrisW67
29th March 2012, 01:05
You appear to be building against Qt 4.7.4, i.e. you have used that version of qmake to build the Makefile. Clean your project and rerun qmake using the one from Qt 4.8.0 if that is the version you wish to use.

The actual error messages imply that the executable is being built 64-bit but the Qt 4.7.4 libraries are 32-bit.

Brit
29th March 2012, 05:31
Thanks for your response. I had tried that earlier, but got the same errors. So, I tried cleaning everything and trying it again, and I still get the same errors. I did notice something interesting though. The link error at the top says that it's linking inside an "i386" directory. XCode is currently set to build the x86_64 architecture. I don't know why there would be any objects in the "i386" folder. Based on the directories and the object-files inside, it looks like it's building all three architectures - i386, ppc, and x86_64.

i386 errors:

Link /Users/Brit/Develop/.../src/build/LunarSim.build/Debug/LunarSim.build/Objects-normal/i386/LunarSim
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/QtWebKit.framework/QtWebKit, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/phonon.framework/phonon, file was built for unsupported file format which is not the architecture being linked (i386)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/QtOpenGL.framework/phonon, file was built for unsupported file format which is not the architecture being linked (i386)
...

And when I scroll down through the build report I see a similar section, except instead of saying "i386" it says "ppc". Is it normal for XCode to build all architectures at the same time? Is there a way to turn it off? Maybe XCode is building the x86_64 version just fine - but I'm still ending up with a ton of errors from the i386 and ppc architectures.

ppc errors:

Link /Users/Brit/Develop/.../src/build/LunarSim.build/Debug/LunarSim.build/Objects-normal/ppc/LunarSim
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/QtWebKit.framework/QtWebKit, file was built for unsupported file format which is not the architecture being linked (ppc)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/phonon.framework/phonon, file was built for unsupported file format which is not the architecture being linked (ppc)
In /Users/Brit/Develop/Qt-4.8/Desktop/Qt/4.8.0/gcc/lib/QtOpenGL.framework/phonon, file was built for unsupported file format which is not the architecture being linked (ppc)
...

ChrisW67
29th March 2012, 06:25
And when I scroll down through the build report I see a similar section, except instead of saying "i386" it says "ppc". Is it normal for XCode to build all architectures at the same time?
By default it would seem so.


Is there a way to turn it off? Maybe XCode is building the x86_64 version just fine - but I'm still ending up with a ton of errors from the i386 and ppc architectures.

I think there's an option like
Project-> Edit Project Settings-> Build-> Build Active Architecture Only

I am not a Mac user though.

Brit
29th March 2012, 07:21
I think I have it figured out now. There was a part of the *.pro file that was adding the other architectures. (Specifically, "CONFIG += x86 ppc".) I removed that line and replaced it with "CONFIG += x86_64" and it isn't trying to build the i386 or ppc architectures.