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

abi*_*ips 12 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
Run Code Online (Sandbox Code Playgroud)

我克隆了几个存储库(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
Run Code Online (Sandbox Code Playgroud)

另外,我无法"hello world"使用rustc 编译简单的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
Run Code Online (Sandbox Code Playgroud)

gcc --version 显示器

gcc (Homebrew gcc49 4.9.2_1) 4.9.2
Run Code Online (Sandbox Code Playgroud)

She*_*ter 7

看起来你已经通过Homebrew安装了GCC和LLVM/clang.检查共享的macOS配置,链接器默认为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
Run Code Online (Sandbox Code Playgroud)

这可能是Rust本身可以解决的问题,但您必须提交错误报告/增强请求.这可能是因为你也许可以通过符号链接来解决此clang作为cc,而不只是混叠它,因为别名可能不生锈从呼叫环境中存在.

  • 对于后代来说,问题是通过`sudo apt-get install gcc`修复了debian (3认同)