我正在编译一个名为“询问”的可执行文件:
g++ -o built/bin/interrogate -Lbuilt/lib -Lbuilt/tmp -L/usr/X11R6/lib \ 建/tmp/interrogate_composite1.o 建/tmp/interrogate_composite2.o \ -lp3cppParser -lp3dtool -lp3dtoolconfig -lp3pystub -pthread -ldl
编译后,当我尝试执行可执行文件时:
$ LD_LIBRARY_PATH=built/lib built/bin/interrogate built/bin/interrogate:符号查找错误:built/lib/libp3dtool.so.1.8:未定义符号:_Py_NoneStruct
此符号由 libp3pystub.so 提供,但询问可执行文件没有对此库的任何引用(我确实使用了 -lp3pystub):
$ LD_LIBRARY_PATH=built/lib ldd built/bin/interrogate linux-vdso.so.1 => (0x00007fff2016a000) libp3dtool.so.1.8 => 内置/lib/libp3dtool.so.1.8 (0x00007f498d57a000) libp3dtoolconfig.so.1.8 => 内置/lib/libp3dtoolconfig.so.1.8 (0x00007f498d51b000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f498d1f2000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f498cfdc000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f498cdbf000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f498c9ff000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f498c7fb000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f498c4ff000) /lib64/ld-linux-x86-64.so.2 (0x00007f498d5bc000)
如果我手动加载 libp3pystub.so,可执行文件有效:
$ LD_PRELOAD=built/lib/libp3pystub.so LD_LIBRARY_PATH=built/lib built/bin/interrogate 用法: 询问 [opts] file.C [file.C ...] 询问 -h
我的问题是:为什么可执行文件-lp3pystub
没有引用我添加的库?interrogate