Search code examples
gcccentos32-bit

Is it possible to compile 32bit target on CentOS 7 with gcc >= 8?


I have an application that needs to be compiled as 32bit on my 64bit CentOS 7. I use -m32 flag for that. I also need features from c++17 so I wanted to install gcc 8.x. I found out that devtoolset 8 comes with gcc 8.2.1 which was good for me.

Application compiles ok but problem is with linking - it cannot find some 32bit libraries:

[100%] Linking CXX executable cherrySim_runner /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find /usr/lib/libstdc++.so.6 /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: skipping incompatible /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++_nonshared.a when searching for -lstdc++_nonshared /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find -lstdc++_nonshared /opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/ld: cannot find /lib/libgcc_s.so.1

What I found is that devtoolset prepared some 32bit libraries but these are links pointing to non existing path e.g.: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/32/libstdc++_nonshared.a -> ../../../i686-redhat-linux/8/libstdc++_nonshared.a . There is no /opt/rh/devtoolset-8/root/usr/lib/gcc/i686-redhat-linux directory at all. I tried few things but nothing seems to be working.

I started to wonder if what I am trying to do is possible at all.

Michał


Solution

  • Unfortunately I found there is no package that would include gcc std libraries for 32bit version of gcc > 8 on CentOS.

    I needed this for my docker image but with not being able to do that I switched to ubuntu i386 16.04 which allows very easy installation of gcc 8.2.