错误:与“ cc”链接失败:退出代码:Linux上为1

时间:2018-10-01 01:53:55

标签: linux rust

我知道有人问过类似的问题(error: linking with `cc` failed: exit code: 1,还有一个issue in the GitHub repo,但我不知道为什么在我的情况下会发生这种情况。

当我尝试运行简单的hello world程序时出现以下错误

kaushalya@computer:~/hello$ cargo run
   Compiling hello v0.1.0 (file:///home/kaushalya/hello)                        
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.1y16o1qfye96o7m0.rcgu.o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.3rngp6bm2u2q5z0y.rcgu.o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.4oc10dk278mpk1vy.rcgu.o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.4xq48u46a1pwiqn7.rcgu.o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.544l4wfz89vbhoea.rcgu.o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.oa3rad818d8sgn4.rcgu.o" "-o" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46" "/home/kaushalya/hello/target/debug/deps/hello-48f1e5d3f3df5b46.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/kaushalya/hello/target/debug/deps" "-L" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-9318d1aa9575dbf9.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e3cd3f44688b2d97.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-2f4890fbea3bd5e0.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-a0ddde720c2c46c5.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-9c41ffe739844496.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-af766b046896c123.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-00b776688b98de66.rlib" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d05a4396ceff8bc8.rlib" "-Wl,--end-group" "/home/kaushalya/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-fe16a4dcdcd95bab.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory
          /usr/bin/ld: cannot find crti.o: No such file or directory
          collect2: error: ld returned 1 exit status

我尝试过:

  1. 重新安装Rust
  2. 检查是否已安装GCC
  3. 通过rustc main.rs直接编译文件(相同错误)

新的Rust编译器似乎有问题。我在rustc 1.29.1 (b801ae664 2018-09-20)上使用Linux mint 18.3,内核版本为

$ uname -a
Linux Computer 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

0 个答案:

没有答案
相关问题