Where does gcc go to link the library?

I have a simple program with jpeg.c and my Makefile was something like this:

all:
    gcc -std=c99 -Wall jpeg.c -o jpeg
clean:
    $(RM) jpeg

      

My code didn't compile until I added "-ljpeg"

all:
    gcc -std=c99 -Wall jpeg.c -o jpeg -ljpeg
clean:
    $(RM) jpeg

      

I'm just wondering where exactly does gcc go looking for the jpeg library as specified in the -l option?

+3


source to share


2 answers


-print-search-dirs

should give you an answer.



+1


source


It defaults gcc

to inline configuration, which gcc

is a file spec

, you can see the spec file referring to a specific executable gcc

with

gcc -dumpspecs

      



docs here .

+1


source







All Articles