问题
I can't seem to find the answer.
I've just used Xcode 4 final version and built an existing project that was built ok with Xcode 3, but got this error:
ld: library not found for -lSystem.B
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
But another project was built OK with Xcode 4.
I installed Xcode 4 by choosing the default options.
Do I miss to include a library or framework somewhere?
Could somebody please help. Thank you.
回答1:
Here's my solution for Xcode 4.0.2 with SDK 4.3 environment, but I believe it should also work on other setups.
libSystem.B.dylib
is not present under/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib
, however it is present for lower SDK versions (e.g.iPhoneOS4.2.sdk
)- most of the cases
libSystem.B.dylib
is just a symbolic link tolibSystem.dylib
- so in
iPhoneSimulator4.3.sdk/usr/lib
I've applied following commandsudo ln -s libSystem.dylib libSystem.B.dylib
and my simulator builds started to work again :)
NOTE: libSystem.B.dylib
is used by Flurry and Urban Airship so you better don't delete the reference in project file (of course Urban Airship does not work under Simulator, but I think Flurry does. libSystem.B.dylib
may also be required by other libraries you included to your project.
UPDATE: solution still works for iOS5 Simulator after upgrading to Xcode 4.3
UPDATE, March 9th, 2k12: for Xcode installations via App Store, prefix above path with /Applications/Xcode.app/Contents
or the path where you've installed Xcode.app.
回答2:
Solved.
Turns out that there was a reference to libSystemB in my project (Don't know why it's there). After deleting the reference, it built well.
Thanks anyway guys!
回答3:
-weak_library /usr/lib/libSystem.B.dylib
breaks the iOS Simulator. Use-weak-lSystem
instead.
The quote belongs to gparker on the official dev forums.
回答4:
-weak_library /usr/lib/libSystem.B.dylib breaks the iOS Simulator. Use -weak-lSystem instead.
nicktmro got it right, especially when you are developing cocos2d projects using xcode 4.x
回答5:
I have the same problem since months and always kept making the symbolic link as described here everytime i updated xCode. Today I found a nice new way to fix this:
In your targets Build Phases go to 'Link Binary With Libraries' and search for: libz.dylib
Set from 'Required' to 'Optional'
BUILD
BE HAPPY
来源:https://stackoverflow.com/questions/5320788/xcode-4-final-version-error-when-building