Search code examples
rustldcc

Compiling issues with Rust language: starting with 'Hello World'


I am using a up2date Linux Mint system which I am using for lots of trial and error projects. Today I stumbled upon Rust and wanted to try it out.

So far so good. Installing Rust was easy and simple.

Used the suggested method, set the environment-variable and performed a update:

  • curl https://sh.rustup.rs -sSf | sh
  • source $HOME/.cargo/env
  • rustup update

So far so good, no errors or other disturbing signals. So after the previous I tried, just like everybody does, compiling the 'Hello world'-example. And here it went sideways. The error:

...
$ rustc main.rs
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" [....... ]"-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
...

My system has cc installed: cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

Does anyone have any idea how I can fix this?


Solution

  • I found an answer that's working for me in other post for Clang: Compiling problems: cannot find crt1.o.

    Answer given by Dmitry Pavlenko works just fine for me too:

    The problem is you likely only have the gcc for your current architecture and that's 64bit. You need the 32bit support files. For that, you need to install

    sudo apt install gcc-multilib