运行 "cargo build" 时无法执行链接器 `cc` 错误
Could not exec the linker `cc` error when running "cargo build"
我刚刚在我的 Mac 和 rustc --version --verbose
显示器上安装了 Rust
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 and erlang-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 编译一个简单的 Rust 文件打印 "hello world"
。我只能通过传递标志 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。查看 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 调用的环境中。
我刚刚在我的 Mac 和 rustc --version --verbose
显示器上安装了 Rust
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 and erlang-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 编译一个简单的 Rust 文件打印 "hello world"
。我只能通过传递标志 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。查看 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 调用的环境中。