[Solved] Error compiling "Hello, World" Program


I am a total noob in this programming field. I am following the book (https://doc.rust-lang.org/book/). But I can’t compile my “Hello, World” program.

This is the error which I get in my terminal —>

error: linking with cc failed: exit code: 1
note: “cc” “-Wl,–as-needed” “-m32” “-L” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib” “main.0.o” “-o” “main” “-Wl,–gc-sections” “-pie” “-nodefaultlibs” “-L” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib” “-Wl,-Bstatic” “-Wl,-Bdynamic” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/libstd-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/libcollections-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_unicode-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/librand-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc_jemalloc-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/liblibc-6a154fe0.rlib” “/usr/local/lib/rustlib/i686-unknown-linux-gnu/lib/libcore-6a154fe0.rlib” “-l” “dl” “-l” “pthread” “-l” “gcc_s” “-l” “pthread” “-l” “c” “-l” “m” “-l” “rt” “-l” "compiler-rt"
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
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

error: aborting due to previous error

Someone else ([solved] “hello world” won’t compile) had the same problem while compiling and got it solved. But I can’t because build-essential package is already installed and the terminal is throwing me the same error while compiling. Please Help.


It looks like you are using a 32-bit version of Rust on a 64-bit operating system. How did you install the Rust compiler? The easiest solution is to install 64-bit Rust instead, by running the install command from the download page.


Or use multirust.
You can install multirust with this command:

curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh


Hahaha. You are right. I was indeed trying to run 32bit version of Rust on 64bit OS. Thanks for solving my problem. Everything is running smoothly now. I am sorry for wasting your precious time. I know I am dumb in these kind of things. By the way, I love this community.


Problem solved.!! Thanks for the tip. Thanks for your precious attention.