0

I am not able compile my c program -m32 option even after installing the gcc-multilib. I am using Ubuntu x86_64 Virtual Machine on Windows. On use of dpkg -l | grep gcc I see

ii  gcc                                        4:7.4.0-1ubuntu2.3                              amd64        GNU C compiler
ii  gcc-11-base:amd64                          11.1.0-1ubuntu1~18.04.1                         amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-7                                      7.5.0-3ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-7-base:amd64                           7.5.0-3ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-7-multilib                             7.5.0-3ubuntu1~18.04                            amd64        GNU C compiler (multilib support)
ii  gcc-8-base:amd64                           8.4.0-1ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-9                                      9.4.0-1ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-9-base:amd64                           9.4.0-1ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-multilib                               4:7.4.0-1ubuntu2.3                              amd64        GNU C compiler (multilib files)
ii  lib32gcc-7-dev                             7.5.0-3ubuntu1~18.04                            amd64        GCC support library (32 bit development files)
ii  lib32gcc-s1                                11.1.0-1ubuntu1~18.04.1                         amd64        GCC support library (32 bit Version)
ii  lib32gcc1                                  1:11.1.0-1ubuntu1~18.04.1                       amd64        GCC support library (dependency package, 32bit)
ii  libgcc-7-dev:amd64                         7.5.0-3ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-9-dev:amd64                         9.4.0-1ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-s1:amd64                            11.1.0-1ubuntu1~18.04.1                         amd64        GCC support library
ii  libgcc1                                    1:11.1.0-1ubuntu1~18.04.1                       amd64        GCC support library (dependency package)
ii  libx32gcc-7-dev                            7.5.0-3ubuntu1~18.04                            amd64        GCC support library (x32 development files)
ii  libx32gcc-s1                               11.1.0-1ubuntu1~18.04.1                         amd64        GCC support library (x32)
ii  libx32gcc1                                 1:11.1.0-1ubuntu1~18.04.1                       amd64        GCC support library (x32)

I am seeing this error

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc

tanmay196
  • 15
  • 6
  • "skipping incompatible" sounds interesting. What platform are you on (`uname -m`)? https://stackoverflow.com/questions/16927885/usr-bin-ld-skipping-incompatible-foo-so-when-searching-for-foo has a few suggestions in the comments. – Allan Wind Feb 08 '23 at 20:31
  • I am using an ubuntu VM – tanmay196 Feb 08 '23 at 20:35
  • Is your VM a x86_64 and you you are trying to cross compile to i386? gcc 9 is previous gen on Debian Stable. Do you have `libgcc-9-dev-i386-cross` and/or `libx32gcc-9-dev-i386-cross` installed? – Allan Wind Feb 08 '23 at 20:36
  • You said you have gcc-multilib installed... is that `gcc-9-multilib-i686-linux-gnu`? – Allan Wind Feb 08 '23 at 20:42
  • It is x86_64. How to check if I have `libgcc-9-dev-i386-cross`? I tried installing it using `sudo apt-get install libgcc-9-dev-i386-cross`, it says unable to locate package. – tanmay196 Feb 08 '23 at 20:45
  • It might be a Debian specific package. What you should do is edit your question with your OS and include `dpkg -l | grep gcc`. – Allan Wind Feb 08 '23 at 20:47
  • It says gcc-7-multilib but your error message suggested you were using gcc-9. Can you install `gcc-9-multilib`? Alternatively, have you tried using gcc-7 as your compiler? – Allan Wind Feb 08 '23 at 21:07
  • Installing gcc-9-multilib resolved the issue. Thanks for your help. – tanmay196 Feb 09 '23 at 08:01

1 Answers1

0

As you use gcc-9 as implied by the error message you want to install the package gcc-9-multilib:

sudo apt-get install gcc-9-multilib
Allan Wind
  • 23,068
  • 5
  • 28
  • 38