Xcode 4 (final version) error when building

我的未来我决定 提交于 2020-01-10 11:09:53

问题


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.

  1. 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)
  2. most of the cases libSystem.B.dylib is just a symbolic link to libSystem.dylib
  3. so in iPhoneSimulator4.3.sdk/usr/lib I've applied following command sudo 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!