Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not compile a simple rust program [duplicate]

Today I decided to learn Rust, however I tried to compile a simple "hello world" program but I get this error:

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

Could someone tell me what's wrong?

like image 796
SSM Avatar asked Nov 11 '18 21:11

SSM


1 Answers

This is a very common problem on MacOS. You can fix it by typing xcode-select --install in terminal. It means developer tools are not installed.

like image 135
CFV Avatar answered Oct 22 '22 14:10

CFV