当运行“货物建造"时,无法执行链接器"cc"错误. [英] Could not exec the linker `cc` error when running "cargo build"
问题描述
我刚刚在Mac上安装了Rust,并且显示了rustc --version --verbose
I just installed Rust on my Mac and rustc --version --verbose
displays
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-extension 和
I cloned a couple of repositories (postgres-extension and erlang-rust-nif) and ran cargo build
upon both of them. Both reported the error
error: could not exec the linker `cc`: No such file or directory (os error 2)
error: aborting due to previous error
此外,我无法使用rustc编译简单的Rust文件打印"hello world"
.我只能通过传递标志rustc -C linker=gcc hello_world.rs
来编译它们.
Additionally, I wasn't able to compile a simple Rust file printing "hello world"
using rustc. I was only able to compile them by passing the flags 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
推荐答案
似乎您已经通过Homebrew安装了GCC和LLVM/clang.查看共享的macOS配置,链接器默认为cc
.我已经安装了macOS开发人员工具:
It looks like you have installed GCC and LLVM/clang via Homebrew. Checking out the shared macOS configurations, the linker defaults to cc
. I have installed the macOS developer tools:
$ 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调用其的环境中可能不存在别名.
This is potentially something that Rust itself could fix, but you'd have to file a bug report / enhancement request. It's possible that you might be able to work around this by symlinking clang
as cc
, instead of just aliasing it, as aliases probably don't exist in the environment that Rust is calling out from.
这篇关于当运行“货物建造"时,无法执行链接器"cc"错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!