在 Xcode 新项目中启用 LLVM + Clang 导致链接错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2999633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:26:07  来源:igfitidea点击:

Enable LLVM + Clang in Xcode new project causes linking errors

xcodecocoalinkerllvm-clang

提问by Ger Teunis

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

我已经完全卸载了 XCode,删除了首选项,删除了完整的 /Developer 文件夹,然后再次重新安装了 XCode。

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.

我创建了一个新的 Cocoa 应用程序,转到 Target,在目标中执行“获取信息”并启用“C/C++ 编译器版本”到“LLVM 编译器 1.0.2”,然后按 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.

任何人都可以帮助我吗?LLVM + GCC 前端确实可以工作,但我真的很想使用 Clang(LLVM 编译器 1.0.2)。新的 XCode 安装,新的 Cocoa 项目仍然有这个问题。

采纳答案by Ger Teunis

I fixed it by creating two symbolic links

我通过创建两个符号链接来修复它

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

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

and

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

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

Thanks for answering guys.

谢谢各位大佬解答。