运行“货物构建”时无法执行链接器“cc”错误

时间:2015-03-13 01:24:29

标签: macos linker rust rust-cargo

我刚在Mac上安装了Rust,rustc --version --verbose显示

rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-08)
binary: rustc
commit-hash: 91bdf23f504f79ed59617cde3dfebd3d5e39a476
commit-date: 2015-03-09
build-date: 2015-03-08
host: x86_64-apple-darwin
release: 1.0.0-nightly

我克隆了几个存储库(postgres-extensionerlang-rust-nif)并在它们两个上运行cargo build。两者都报告了错误

error: could not exec the linker `cc`: No such file or directory (os error 2)
error: aborting due to previous error

此外,我无法使用rustc编译打印"hello world"的简单Rust文件。我只能通过传递标志rustc -C linker=gcc hello_world.rs来编译它们。

clang --version显示

clang version 3.4.2  (http://llvm.org/git/llvm.git 5c6aa738fb3325ae499454877f1e2926d2368135)
Target: x86_64-apple-darwin12.2.1
Thread model: posix

gcc --version显示

gcc (Homebrew gcc49 4.9.2_1) 4.9.2

1 个答案:

答案 0 :(得分:7)

看起来你已经通过Homebrew安装了GCC和LLVM / clang。签出shared macOS configurations,链接器默认为cc。我已经安装了macOS开发人员工具:

$ clang --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

$ cc --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix

这可能是Rust本身可以解决的问题,但您必须提交错误报告/增强请求。您可以通过将clang符号化为cc来解决此问题,而不仅仅是别名,因为在Rust调用的环境中可能不存在别名。