Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/ld: cannot find -lgcc - Error in the linkage of assembly

I am trying to compile in Linux Mint 17.2 a main.c code and assembly code pstring.s.

When I try to link the codes, the gcc returns: /usr/bin/ld: cannot find -lgcc.

Does anyone know what I need to change in order to make it work?

gcc -m32 -g -c -o pstring.o pstring.s 

shay@shay-Latitude-E6410~/workspace1/targ3Mivne $ gcc -m32 -g -c -o main.o main.c

shay@shay-Latitude-E6410 ~/workspace1/targ3Mivne $ gcc -m32 -g -o a.out main.o pstring.o

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

/usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for
-lgcc_s /usr/bin/ld: cannot find -lgcc_s 

collect2: error: ld returned 1 
exit status
like image 979
Shay Chercavsky Avatar asked Sep 19 '25 11:09

Shay Chercavsky


1 Answers

Try installing these packages with the command sudo apt-get install gcc-multilib g++-multilib

Without multilib the 32-bit version of libgcc isn't available. The 64-bit one can't be linked to 32-bit code which is the reason for the error in this question. – Michael Petch

like image 123
Armali Avatar answered Sep 21 '25 02:09

Armali