【发布时间】:2012-08-02 21:37:11
【问题描述】:
如果我在 make 文件中有这一行:\
libpqxx_Libs = -L/share/home/cb -lpqxx-2.6.9 -lpq
这是否表明编译器使用 lpqxx-2.6.9.so 共享对象文件,或者这是否表明编译器使用文件夹 lpqxx-2.6.9 中的所有 .so?还是这完全是另外一回事?
感谢您的帮助!
【问题讨论】:
如果我在 make 文件中有这一行:\
libpqxx_Libs = -L/share/home/cb -lpqxx-2.6.9 -lpq
这是否表明编译器使用 lpqxx-2.6.9.so 共享对象文件,或者这是否表明编译器使用文件夹 lpqxx-2.6.9 中的所有 .so?还是这完全是另外一回事?
感谢您的帮助!
【问题讨论】:
-L 在此上下文中是链接器的一个参数,它将指定的目录添加到链接器将搜索必要库的目录列表中,例如您使用 -l 指定的库。
它不是一个 makefile 命令,尽管它通常出现在 C 项目的 makefile 中。
【讨论】:
-L 实际上不是 makefile 命令(正如您在问题标题中所述)。
在这一行中实际发生的是对变量libpqxx_Libs 的赋值——不多也不少。您必须在 makefile 中搜索通过 $(libpqxx_Libs) 或 ${libpqxx_Libs} 使用该变量的位置。这很可能是链接命令或包含链接的编译命令中的参数。
在这种情况下,-L 和-l 的含义可以在例如gcc man pages 中找到,其中指出
-llibrary
Use the library named library when linking.
The linker searches a standard list of directories for the li-
brary, which is actually a file named `liblibrary.a'. The linker
then uses this file as if it had been specified precisely by
name.
The directories searched include several standard system direc-
tories plus any that you specify with `-L'.
【讨论】: