无法编译简单的 rust 程序
Can not compile a simple rust program
今天我决定学习并开始使用 Rust 编程,因为它是一种非常有前途的语言。但是,我尝试用 Rust 编译并 运行 一个简单的 Hello world 程序,但由于某种原因出现此错误。谁能告诉我怎么了?
这是我的 Rust 代码:
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 编程,因为它是一种非常有前途的语言。但是,我尝试用 Rust 编译并 运行 一个简单的 Hello world 程序,但由于某种原因出现此错误。谁能告诉我怎么了?
这是我的 Rust 代码:
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
来修复它。
这意味着开发者工具没有安装。