Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

monsieurpaul

macrumors regular
Original poster
Oct 8, 2009
230
0
Hello all,

I have made an app using an external C library: libqrencode, installed using Macports.

I am using XCode 3.2.5 on a MacBook Pro Mid 2009.

The debug version builds just fine. However, the release build gives me the warning: "in /opt/local/lib/libqrencode.3.dylib, file was built for unsupported file format which is not the architecture being linked (i386)" with undefined symbols errors.

I have tried several configuration:

For Mac OS X 10.6 SDK:
  • Debug | x86_64 : works fine
  • Debug | i386 : error
  • Release | x86_64 : error
  • Release | i386 : error

For Mac OS X 10.5 SDK:

  • Nothing compiles.

I have checked the header, user, library, framework search path for each configuration.

Any suggestions ?
 
Last edited:
Because the library is 64-bit only. The default switches for compiling under debug are for your architecture only. The default for compiling under "Release" I think is to compile a "fat" binary with 32-bit and maybe PPC code as well. Since you have an external 64-bit only library you need to change the switches so that the "release" build compiles only for 64-bit. But this means you won't be able to run your app on older non-64-bit capable hardware. Or PPC Macs.
 
I had a lot of fun with Macports, gcc and Xcode last night…

As mfram pointed out, my library was not compiled for the all the necessary architectures.

1) I first tried reinstalling the lib with Macports using install +universal : I got a lib with “fat” binary including i386 and x86_64, checked with
Code:
$ file /opt/local/lib/libqrencode.dylib
The result was that the Debug i386 and x86_64 versions were working, but still no luck with the release builds.

2) I reinstalled the library from scratch with ./configure, make, make install. I had to use the following command lines:
Code:
$ ./configure CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch x86_64" CPP="gcc -E" CXXCPP="g++ -E"
$ make
$ sudo make install
(To be perfectly honest, I still don’t understand all the arguments in this command…). I had to reinstall another library (libpng12) using the same arguments. The “fat” binary in /usr/local/lib now included i386 and x86_64.
The build results (using now /usr/local/ instead of opt/local/) was the same: Debug x86_64 and i386 working, Release versions not working.

3) I tweaked my project info in Xcode to keep only the following valid architectures: x86_64 and i386. IT WORKED !! On the other hand, the release version was now intel only (This is what I believe though).

4) In order to add ppc support, I manually reinstalled the library (and libpng12 prior to that) using the following command lines:
Code:
$ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc" CXX="g++ -arch i386 -arch x86_64 -arch ppc" CPP="gcc -E" CXXCPP="g++ -E"
$ make
$ sudo make install
Now, the release version works for the following architectures: x86_64, i386, ppc970, ppc7400, ppc64. (No ppc though, but that will do !)

5) I uninstalled the Macports version (port –f uninstall installed) because I am not comfortable with 2 different versions of the same library in my computer. No impact on my builds as I am using the library located in /usr/local/lib/.

It’s a long post on a really minor problem, but for me it’s a great victory in my personal war against the machines...

..or not, because I still haven’t tested my app on another mac… Is there a way to do so virtually ?
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.