7

Moving a project to Xcode 4.2, I am getting a number of Mach-O linker unresolved errors, for things like _crc32, _expf, and _UnwindSjLj_Register, on a project that compiles and links fine in Xcode 4.0.3.

I suspect this might be a libz issue, since my previous project linked libz.1.2.3.dylib. I removed that reference, and added libz.1.2.5.dylib, that is found in my /Platforms/iPhoneOS.platform/DeviceSupport/5.0 (9A5259f)/Symbols 1/usr/lib folder.

I get the same 39 unresolved references whether I include libz.1.2.5.dylib or not, so it seems very suspicious.

Andrew Smith
  • 2,919
  • 2
  • 22
  • 25

3 Answers3

30

Link against the libz.dylib, but add it through the Build Phases tab.

Project >> Target >> Build Phases >> Link Binary With Libraries

Press + under the list and select the libz.dylib then it will add the lib so it will work inbetween SDK updates.

epatel
  • 45,805
  • 17
  • 110
  • 144
  • Thanks, did that, and it does link that lib now in either SDK. Thanks. – Andrew Smith Jul 21 '11 at 18:55
  • @epatel, Not related to the question, but I can't find this in google. can I use XCode 4.2 in Snow Leopard, or is Lion required? I will really be grateful, if you answer. Thanks a lot! – Özgür Jul 22 '11 at 23:41
  • 1
    @Comptrol If you log into developer.apple.com you will find two different downloads, one for Lion and one for Snow Leopard. – epatel Jul 23 '11 at 09:27
  • This doesn't seem safe to me. What's the general difference between 1.2.3 and 1.2.5? What exactly is happening when you link to `libz.dylib` instead of `libz.1.2.3.dylib` or `libz.1.2.5.dylib`? – Hyperbole Aug 03 '11 at 20:29
  • 2
    @Hyperbole if you check you will notice that `libz.dylib` in the SDK is actually a file link to one of the versioned dylibs (often the latest). But there is only one header version, which will have the same version as the latest. So, if you then try to link against (in xcode) 1.2.3 today, and the SDK is updated, including libz to 1.3.0 with updated header you will be still linking against the old version (but if you used libz.dylib you would link agains same as the headers)...well, something like that, but each lib can have their own requirements – epatel Aug 03 '11 at 20:49
0

Had a problem with this same lib - libz.1.2.3.dylib. As suggested, I added libz.dylib. still got the message "ld: Library not found for -lz.1.2.3". Removed the reference build succeeded. Tried replacing libz.dylib with libz.1.2.5.dylib and still built without error. XCode 4.3.2, Lion (OS X 10.7.4)

BobFromBris
  • 261
  • 4
  • 6
0

I had same problem. it works xcode 4.2 .when i run the app in xcode 4.5. I have this problem. libz.dylib (No such file or directory)Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool failed with exit code 1. I have tried with libz1.2.5dylib.but no use

prem
  • 1
  • 3