PDA

View Full Version : Linking to dylib fails on release build setting




davbeck
Oct 6, 2008, 04:31 PM
I am trying to use a dylib (libgeotiff) with a c program in Xcode. When I compile it with build configuration debug, it compiles fine and runs without error. But when I switch to Release, I get a linking error for every function in the dylib.

My first thought was that the library was not compiled with universal support, which it wasn't. So using Porticus, I reinstalled it with universal. The utilities that come with it were compiled correctly with universal, I am not sure how to check the dylib.



Sayer
Oct 6, 2008, 06:18 PM
You can check a dylib by opening the Terminal and typing:

lipo -info /path/to/dylib

That will tell you if its a "Fat" binary or not.

bobrik
Oct 6, 2008, 06:46 PM
with build configuration debug, it compiles fine and runs without error. But when I switch to Release, I get a linking error for every function in the dylib.


I am shooting a bit blind here since I am used to Visual Studio and not XCode, but I have seen same thing with Visual Studio and it's always that you tell your project to link to the library, but when you are in debug configuration. What you forget (don't realize) is that you need also to switch configuration to release and there to specify to link to that library as well. Maybe that's it?

davbeck
Oct 6, 2008, 09:54 PM
I was able to bring in all the source files and what not from the library and build it there. It took me a while to recreate all the make settings, but I eventually got it to compile correctly. For whatever reason, no matter what variables got set, the library would not compile for universal.