Makefile 生成过程使用哪些库?

Makefile 生成过程使用哪些库?,makefile,Makefile,我的构建无法链接,可能是因为它试图链接到错误版本的库(即libssl)。makefile的LIBS指令指定了-lssl,这不够明确:我的系统上有很多这样的命令(各种系统SDK+新下载的版本) 我的一般问题是,是否有详细选项让打印用于链接的libs的显式路径 Gil.要详细查看链接步骤,通常需要将“verbose”选项传递给编译器或链接器。你用的是什么系统?如果是gcc,则在compile命令中添加-v。这将产生像这样的输出 $ gcc -v hello.c Using built-in spec

我的构建无法链接,可能是因为它试图链接到错误版本的库(即libssl)。makefile的LIBS指令指定了-lssl,这不够明确:我的系统上有很多这样的命令(各种系统SDK+新下载的版本)

我的一般问题是,是否有详细选项让打印用于链接的libs的显式路径


Gil.

要详细查看链接步骤,通常需要将“verbose”选项传递给编译器或链接器。你用的是什么系统?如果是gcc,则在compile命令中添加
-v
。这将产生像这样的输出

$ gcc -v hello.c
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/ccAtBXVy.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
GNU C version 4.1.2 20080704 (Red Hat 4.1.2-50) (i386-redhat-linux)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-50).
GGC heuristics: --param ggc-min-expand=81 --param ggc-min-heapsize=95810
Compiler executable checksum: d8d95095eb3c93dae4bed2137d559f95
 as -V -Qy -o /tmp/ccDL1N2O.o /tmp/ccAtBXVy.s
GNU assembler version 2.17.50.0.6-14.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-14.el5 20061020
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.. /tmp/ccDL1N2O.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o
$gcc-v hello.c
使用内置规格。
目标:i386 redhat linux
配置为://Optry-前缀=/UR——Navrr= /Urs/Stuts/Man——InfDIr= /Ur/Stuty/Fielo——启用共享-启用线程= POSIX启用启动检查=释放-使用系统ZLIB启用-OX-CXAYATUSTEX-禁用LyBunWrand异常-启用LBGCJ多文件-使能语言= C、C++、Objc、Obj-C++、java、FORTRAN,ada--启用java awt=gtk--禁用dssi--禁用插件--使用java home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre--使用cpu=generic--主机=i386 redhat linux
线程模型:posix
gcc版本4.1.2 20080704(Red Hat 4.1.2-50)
/usr/libexec/gcc/i386 redhat linux/4.1.2/cc1-quiet-v hello.c-quiet-dumpbase hello.c-mtune=generic-auxbase hello-version-o/tmp/ccAtBXVy.s
忽略不存在的目录“/usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../i386 redhat linux/include”
#包括“…”搜索从这里开始:
#包括搜索从这里开始:
/usr/本地/包括
/usr/lib/gcc/i386 redhat linux/4.1.2/include
/usr/包括
搜索列表结束。
GNU C版本4.1.2 20080704(Red Hat 4.1.2-50)(i386 redhat linux)
由GNU C版本4.1.2 20080704(Red Hat 4.1.2-50)编译。
GGC启发式:--param GGC min expand=81--param GGC min heapsize=95810
编译器可执行校验和:d8d95095eb3c93dae4bed2137d559f95
as-V-Qy-o/tmp/ccDL1N2O.o/tmp/ccAtBXVy.s
GNU汇编程序版本2.17.50.0.6-14.el5(i386 redhat linux),使用BFD版本2.17.50.0.6-14.el5 20061020
/usr/libexec/gcc/i386 redhat linux/4.1.2/collect2--eh frame hdr-m elf_i386--hash style=gnu-dynamic linker/lib/ld linux.so.2/usr/lib/gcc/i386 redhat linux/4.1.2/../../crt1.o/usr/lib/gcc/i386 redhat linux/4.1.2/../../../crti.o/usr/lib gcc/i386 redhat linux/4.1.2/tbegin.o-L/usr/gcc/1.2-L/usr/lib/gcc/i386 redhat linux/4.1.2-L/usr/lib/gcc/i386 redhat linux/4.1.2/../....//tmp/ccDL1N2O.o-lgcc-as needed-lgcc_s-no-as needed-lc-lgcc-as needed-lgcc_s-no-as needed/usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o/usr/lib/gcc/i386-redhat-linux/4.1.2/../../crtn.o

其中最后一行是链接命令的全部荣耀。
-L
选项指定按顺序搜索由
-L
给出的lib的目录。

链接器命令行指定-lgcc\s,但是您在此处放置的输出不显示该库的完整路径。这正是我所缺少的。在我的例子中,我确实看到了许多-L选项,库可以在其中任何一个中。我只是想知道链接器试图链接的是哪一个。首先找到的是通过依次查找
-L
目录。你的意思是,我必须逐个查找十几个目录中的每一个,直到找到使用的库?绝对没有链接器详细的实际使用的文件?我建议您阅读您的链接器手册页,看看是否有一个选项。另一方面,您可以尝试使用
strace
跟踪open()系统调用,以查看读取了哪些文件。