Enable LLVM + Clang in Xcode new project causes linking errors

牧云@^-^@ 提交于 2019-12-05 05:48:48

问题


I've done a complete clean uninstall of XCode and deleted the prefs and deleted complete /Developer folder and reinstalled XCode again.

I create a new Cocoa application, go over to Target, doing a "Get info" in the target and enable "C / C++ compiler version" to "LLVM compiler 1.0.2" and press Build.

I get:

ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found
ld: warning: directory '/usr/lib/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1' following -L not found
ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../..' following -L not found
ld: library not found for -lgcc
Command /Developer/usr/bin/clang failed with exit code 1

Anyone able to help me here? LLVM + GCC frontend does work though but I really would like to use Clang (LLVM compiler 1.0.2). New XCode install, new Cocoa project still have this issue.


回答1:


I had a similar problem when I converted my project to use a custom .xcconfig file (similar to what this person wanted). After setting the custom .xcconfig file for the basis of my build, I saw similar linker errors. I set the "C++ Standard Library Type" build setting to "Static" and now it builds just fine.




回答2:


I fixed it by creating two symbolic links

/usr/lib/gcc -> /Developer/usr/lib/gcc

and

/usr/lib/i686-apple-darwin10 -> /Developer/usr/lib/i686-apple-darwin10/

Thanks for answering guys.



来源:https://stackoverflow.com/questions/2999633/enable-llvm-clang-in-xcode-new-project-causes-linking-errors

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