根据g++ -print-search-dirs,我的C++编译器正在许多目录中搜索库,包括.
天真地说,/lib/../lib/似乎与/lib/ - lib的父母将有一个名为lib的子目录相同,“那个人的父亲的儿子就是我父亲的儿子”等等。/usr/lib/../lib/和/usr/lib/也是如此
/lib/../lib/和/lib/?如果这很重要,在未经修改的Ubuntu9.04安装上就会观察到这一点。
编辑:更多信息。
结果是在没有其他开关的情况下从bash执行g++ -print-search-dirs。
LIBRARY_PATH和LPATH都不是从printenv输出的,echo $LPATH和echo LIBRARY_PATH都返回空行。
发布于 2009-06-13 10:09:34
试图给出一个答案(我从查看gcc.c驱动程序源代码和Makefile环境的几分钟中得到了答案)。
这些路径是在运行时从以下方面构造的:
GCC_EXEC_PREFIX)$LIBRARY_PATH环境变量$LPATH环境变量(它被视为$LIBRARY_PATH)-B命令行开关的任何值最后一个(tooldir前缀)通常被定义为一个相对路径:来自gcc的Makefile.in
# Directory in which the compiler finds libraries etc.
libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)
# Directory in which the compiler finds executables
libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version)
# Used to produce a relative $(gcc_tooldir) in gcc.o
unlibsubdir = ../../..
....
# These go as compilation flags, so they define the tooldir base prefix
# as ../../../../, and the one of the library search prefixes as ../../../
# These get PREFIX appended, and then machine for which gcc is built
# i.e i484-linux-gnu, to get something like:
# /usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../i486-linux-gnu/lib/../lib/
DRIVER_DEFINES = \
-DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
-DTOOLDIR_BASE_PREFIX=\"$(unlibsubdir)/../\" \然而,这些都是针对编译器版本的特定路径.您的示例可能受到我前面列出的环境变量(LIBRARY_PATH、LPATH)的影响。
发布于 2009-06-13 09:30:54
理论上,如果/lib是/drive2 2/foo的一个符号链接,那么如果我没有弄错,那么/lib/./lib将指向/drive2 2/lib。理论上..。
编辑:我刚刚进行了测试,但事实并非如此,而是回到了/lib。人力资源管理:(
https://stackoverflow.com/questions/990370
复制相似问题