Linking with `cc` failed: exit code: 1


#1

Hi,

I installed rust like a year back and I am updating it regularly. A week back I got an error
as in title. Full trace back is as follows.

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice0.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice1.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice10.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice11.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice12.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice13.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice14.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice15.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice2.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice3.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice4.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice5.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice6.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice7.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice8.rust-cgu.o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.practice9.rust-cgu.o" "-o" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e" "/home/dinesh/projects/practice/target/debug/deps/practice-6f3c90a32c93c78e.crate.allocator.rust-cgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/dinesh/projects/practice/target/debug/deps" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-fe0b1b991511fcaa.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-3d7b10e850a67e89.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-28484309357fd6f1.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-751808ba756769d5.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-8cb97051d8238386.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-25cc9b024a02d330.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d42e80cee81b06ce.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-78c21267a2dc15c1.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-0e1b544c94586415.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0c5e3d6c117f8c44.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-bd7cc5ada1e908e0.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
  = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory
          collect2: error: ld returned 1 exit status

As it says Scrt1.o file not found. I worked around and I figured the problem, to specify ld library path in bashrc.

LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
export LIBRARY_PATH

This works well in terminal. But If I am compiling the file in emacs using cargo package, I get the same error.
Well, even before compiling it complains on the first line as linking failed with cc.

Any help!

Thank you.


#2

Do you have gcc installed?

This is that I can see for now :confused:


#3

I am using Ubuntu. Yes I have gcc installed


#4

Quickly looking on google, it is possible that you don’t have the 32 bit version of Scrt1.o.

Can you give us the output of locate crt1.o ?


#5

I get this when locating the crt1.o

/home/dinesh/anaconda3/envs/fenicsproject/lib/crt1.o
/home/dinesh/anaconda3/envs/fenicsproject/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crt1.o
/home/dinesh/anaconda3/lib/crt1.o
/home/dinesh/anaconda3/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crt1.o
/home/dinesh/anaconda3/pkgs/gcc-4.8.5-7/lib/crt1.o
/usr/lib/x86_64-linux-gnu/Mcrt1.o
/usr/lib/x86_64-linux-gnu/Scrt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
/usr/lib/x86_64-linux-gnu/gcrt1.o


#6

If I could read better it would be great…

Do you launch emacs from terminal too ?
Did you try to put this export in .profile instead (so that it is kept for the entire session and not just terminal session) ?
If both of those do not work, you will have to see what’s wrong with emacs.


#7

Cool! It worked.


#8

Nice !
I could have helped you faster, but I have a tendency to not read the posts enough :smile: