0

I know that similar questions have been asked (error: linking with `cc` failed: exit code: 1) and there is also an issue in the GitHub repo, but I could not figure out why this is happening in my case.

I get the following error when I am trying to run simple hello world program

username@computer:~/hello$ cargo run
   Compiling hello v0.1.0 (file:///home/username/hello)                        
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.1y16o1qfye96o7m0.rcgu.o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.3rngp6bm2u2q5z0y.rcgu.o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.4oc10dk278mpk1vy.rcgu.o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.4xq48u46a1pwiqn7.rcgu.o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.544l4wfz89vbhoea.rcgu.o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.oa3rad818d8sgn4.rcgu.o" "-o" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46" "/home/username/hello/target/debug/deps/hello-48f1e5d3f3df5b46.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/username/hello/target/debug/deps" "-L" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-9318d1aa9575dbf9.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e3cd3f44688b2d97.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-2f4890fbea3bd5e0.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-a0ddde720c2c46c5.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-9c41ffe739844496.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-af766b046896c123.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-00b776688b98de66.rlib" "/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d05a4396ceff8bc8.rlib" "-Wl,--end-group" "/home/username/.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

I have tried:

  1. Reinstalling Rust
  2. Checking whether GCC is installed (it is)
  3. Directly compiling the file via rustc main.rs (same error)

It seems to be issue with the new Rust compiler. I am using rustc 1.29.1 (b801ae664 2018-09-20) on Linux mint 18.3 , Kernel version is

$ 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
user158
  • 12,852
  • 7
  • 62
  • 94
  • 2
    See also [crti.o file missing](https://stackoverflow.com/q/91576/155423) — Have you installed the proper dependencies for your system? – Shepmaster Oct 01 '18 at 02:04
  • 2
    @Shepmaster thank you very much for support, I fixed the issue by installing libc6-dev. Really happy about Rust community. – user158 Oct 01 '18 at 02:23
  • To install the developer package command: sudo apt-get install libc6-dev – hkiame Jan 19 '20 at 14:59

0 Answers0