Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If there are multiple directories in LDFLAGS, how does the linker know where to look first?

Tags:

linux

makefile

If I have two libraries with the same library name but stored in different directories (and they may contain different code) and I list both directories in the LDFLAGS variable in a makefile, how does the linker know where to look first and which library to use?

  LDFLAGS+= \
        -L${INSTALL_DIR}/lib\
        -L${EVO_INSTALL_DIR}/lib\

Will it look in the INSTALL_DIR path first or in the EVO_INSTALL_DIR path?

like image 618
user1655072 Avatar asked Dec 05 '25 12:12

user1655072


1 Answers

INSTALL_DIR. It will look in the order they are listed.

By the way, it's your linker (probably the same program as your compiler) that's making this choice, not the Makefile. Make (which is reading your Makefile) only runs the build tools.

like image 126
Collin Avatar answered Dec 08 '25 20:12

Collin