Ubuntu C linker - what is it?

So I understand very little about compiling and linking, but it was easy enough to get Rust running on an Ubuntu desktop system with gcc-5 as the 'linker'.

Now I am trying to do a minimal install on an Ubuntu Touch phone (16.04 based system, search ubports for more info) to tinker with Rust code on the go as I learn the basics. The difficulty is that the system on a phone is read-only image based, meaning it is a bit of a hack to install gcc-multilib on the system for Rust to compile (Rust itself installs and runs just fine in ~/.cargo).

What my question is: what exactly is rustc calling when I get the 'error: linker cc not found' message?

My limited understandingis that the linker used on an Ubuntu system would be the 'ld' command, however this is installed on my system by default but compilation does not work until I hack on gcc-multilib. Aiming for a minimal install, what is missing? Do I need to install all of gcc-multilib?

I am confused, thanks in advance.

By default for GNU targets, Rust uses gcc for linking, and gcc in turn calls ld but takes care of passing a bunch of toolchain-specific arguments like the locations of the "crt" files. You will need at least the gcc package for this to work, though you probably don't need gcc-multilib if you are compiling for the default architecture.

Alright, that would explain things. I have tested and I definitely need gcc-multilib for some reason. Installed, gcc-5 returns the same error as without it.

I see the package contents but it really doesn't enlighten me.

How would I go about following the comand sequence rustc issuses?

Install the package gcc, which should make GCC the default compiler and create the /usr/bin/cc symlink.

With a nightly version of Rust, you can use RUSTFLAGS="-Z print-link-args" to see the linker command line.

I am still working on this but it is clear that my knowledge of gcc is very lacking. I can sort of see what is happening now, but the software is too complex for me to work out. It seems I would basically need a standalone installation of gcc, and that doesn't really exist.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.