I would like to build a simple hello world C program for linux in 32 bit. I tried to do it with docker ( because the OS on my machine is not Linux )
This is the Dockerfile:
FROM gcc:4.9
RUN dpkg --add-architecture i386
RUN apt-get update && apt-get install -y libc6-dbg libc6-dbg:i386 gcc-multilib libc-dev:i386 gcc-4.9-base:i386
I build it like this:
docker build -t my-gcc .
Then I try to use it like this:
docker run --rm -v ${pwd}:/usr/src/myapp -w /usr/src/myapp my-gcc gcc -m32 -o hello hello.c
I get this error:
/usr/bin/ld: skipping incompatible /usr/local/lib/gcc/x86_64-linux-gnu/4.9.4/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
What do I wrong? How is it possible to fix it?
I've found similar questions, but they suggest gcc-multilib, which I already installed.
The host machine is Windows 10 x64, with WSL2. But as far as I know, this should not matter. I would like to build x86 32bit linux binaries with gcc.