Linux -m32 gcc compiling error


Jan 20, 2016
I keep trying to compile a program I am running in linux using -m32.

I keep getting this error.

gcc -g -m32 encrypt.c -o encrypt
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 1

I googled and learned that running this command should fix it.
sudo apt-get install gcc-multilib g++-multilib

but I am still getting the same errors.

I also did a gcc and g++ upgrade following these instructions to see if that would fix it

but I am still getting the same errors.
Those are linker errors. gcc is attempting to link against the gcc std library (libgcc; btw, gcc always requires it), and since you're explicitly targeting 32-bit, the linker can't seem to find the 32-bit libgcc library to link against. I would suggest (re)installing gcc-multilib, but it seems you already tried that. So the next thing to try is add:


And that should force it to look there (although it should be looking there anyway).

And if that doesn't work, try (re)installing libc6-dev-i386.

And if that doesn't work.... well, I'm out of ideas. If you're using a Makefile, etc. make sure it's not overriding your lib paths.

Edit: One more question: Are you using the system default (gcc) compiler? If not, you'll have to (explicitly) install the matching version, i.e.

sudo apt install gcc-x.x-multilib

By default, you'll install the version matching the system default compiler. Linking against the correct version of the stdlib matters here.
Last edited:
This is probably the wrong forums for help with this issue, but I'll start with the most obvious. Is there a reason why you need gcc 6? Just looking at distrowatch's nice table, GCC 4.x was used for the absolute longest time, and only in the last couple version of Ubuntu did the complier get version bumped. I don't know where your source code is coming from, but if it's based on anything older than 2 - 3 years, it might not run on a newer version. I could be completely wrong and it's a non issue, but just something worth checking to make sure some part of your code hasn't been depreciated.

My first thought was what Absalom said though, you're having issues because it's mixing 32bit and 64 bit libraries. It's wanting to use a 32bit library, but it's being pointed at a 64 bit one.
Last edited: