3

如果我有两个具有相同库名称但存储在不同目录中的库(并且它们可能包含不同的代码)并且我在 makefile 的 LDFLAGS 变量中列出了这两个目录,那么链接器如何知道首先查找的位置以及要使用的库?

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

它会先查看 INSTALL_DIR 路径还是查看 EVO_INSTALL_DIR 路径?

4

1 回答 1

3

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.

于 2012-11-02T19:06:29.723 回答