rust - 无法在 MacOS 上编译简单的 Rust 程序

标签 rust rust-cargo

<分区>

今天我决定学习 Rust,但是我试图编译一个简单的“hello world”程序但是我得到了这个错误:

fn main() {
    println!("Hi");
}
error: linking with `cc` failed: exit code: 1
   |   = note: "cc" "-m64" "-L" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "test.test.7rcbfp3g-cgu.0.rcgu.o" "test.test.7rcbfp3g-cgu.1.rcgu.o" "test.test.7rcbfp3g-cgu.2.rcgu.o" "test.test.7rcbfp3g-cgu.3.rcgu.o" "test.test.7rcbfp3g-cgu.4.rcgu.o" "test.test.7rcbfp3g-cgu.5.rcgu.o" "-o" "test" "test.5fi6c8ty3hqyycqf.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-a5984f6fc2a4870f.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-7c9487d161f01b59.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-e146b9b98ab73364.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-acb39784a181deae.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-89f97a4bae8c89d2.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-cd336d4bb1fade3c.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-d6545438808205eb.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-8aa8397108285683.rlib" "/Users/moo7md/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-83c21e81fef8188c.rlib" "-lSystem" "-lresolv" "-lpthread" "-lc" "-lm"
   |   = note: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

谁能告诉我哪里出了问题?

最佳答案

这是 MacOS 上非常常见的问题。 您可以通过在终端中键入 xcode-select --install 来修复它。 这意味着未安装开发者工具。

关于rust - 无法在 MacOS 上编译简单的 Rust 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53253483/

相关文章:

rust - Option::map 的结果不够长

arrays - 使用 #[!no_std] 通过 FFI 将数组从 C 传递到 Rust

rust - 我如何生成一个随机 num::BigUint?

file - 过滤使用 fs::read_dir() 发现的文件或目录

file - 如何将二进制数写入文件并在 Rust 中检索它

rust - Cargo 无法在 Windows 10 上编译 rust-qml

rust - 如何在 Rust 的内部特征上实现外部特征?

cmake - 我该如何修复 "The CMAKE_C_COMPILER is not a full path and was not found in the PATH"?

api - 我正在尝试通过 Rust 中的 OpenWeather API 获取数据,但我想我正面临一些关于解析的问题

rust - 无法构建 Rocket.rs : The given version requirement is invalid