G ++ ld link library not

I would like to know why

g++ test1.o test2.o -o test.x -lgtk-x11-2.0

works well

ld 'r test1.o test2.o -o test.o -lgtk-x11-2.0

gives:

ld: cannot find -lgtk-x11-2.0

unless I explicitly include the path adding -L/usr/lib/i386-linux-gnu

I tried everything, adding a path to $LD_LIBRARY_PATHor ld.so.conf, but nothing works, and I can not explain myself the difference between the two calls.

The ld manual states:

The default set of found paths (without specifying the -L name) depends on which ld mode is used for emulation, and in some cases also on how it was configured.

but when trying to use different emulations (using the -m * emulation), segfault is implied (possibly because the default emulation elf_i386 is correct).

Can you help me shed some light on this topic?

+3
source share
2 answers

, ld

ld --verbose | grep SEARCH

ld , , gcc, .

gcc

gcc -dumpspecs

, gcc, , , gcc, , , .

, gcc, , , gcc , , .

;

gcc , , , .

+1

gcc -print-search-dirs ( g++) , ; /usr/lib/i386-linux-gnu, , . gcc, .

-v: g++ -v test1.o test2.o -o test.x -lgtk-x11-2.0 , .

+1

All Articles