Why were some libraries unable to open?

I wrote a simple C program, prova.c
int main() {return 0;}


I wanted to look at the libraries that were linked to it, so:

  • I compiled it with gcc -Wall -m32 -stdc=99 -c prova.c -o prova.o

  • I tied it up gcc -m32 -Wl,--verbose prova.o -o prova

Now when I examine my source code, I noticed that some libraries did not open.
Why is this happening? Why are they trying to open them? Why does it fail?

attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/crt1.o succeeded
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/crt1.o
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/crti.o succeeded
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib32/crti.o
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/32/crtbegin.o succeeded
/usr/lib/gcc/x86_64-linux-gnu/4.8/32/crtbegin.o
attempt to open prova.o succeeded
prova.o
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/32/libgcc.so failed
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/32/libgcc.a succeeded
attempt to open /usr/lib/gcc/x86_64-linux-gnu/4.8/32/libgcc_s.so succeeded

      

+3


source to share


1 answer


The compilation command has a shadow suffix -lgcc -lc

added by the compiler driver. This flag does not tell the linker exactly where libgcc and libc are located, nor does it tell the linker whether they should be static or shared. Therefore, the linker tries many times to find them in different directories (passed from the compiler via -L

or to the linker script). By default, the linker tries to link the shared library version first ( .so

), then the static version ( .a

).



The warnings you see attempt to open ... failed

are not real failures, but diagnostic messages about the progress of the linker in the search for the required libraries.

+2


source







All Articles