我想将/opt/vertica/lib64添加到系统库路径中,因此我执行以下步骤:
(1)将/opt/vertica/lib64添加到/etc/ld.so.conf中,然后运行ldconfig
(2)检查:

 bash# ldconfig -p | grep vertica
    libverticaodbc.so (libc6,x86-64) => /opt/vertica/lib64/libverticaodbc.so
    ......

但是当我运行“ld -lverticaodbc --verbose”命令时:
==================================================
attempt to open /usr/x86_64-redhat-linux/lib64/libverticaodbc.so failed
attempt to open /usr/x86_64-redhat-linux/lib64/libverticaodbc.a failed
attempt to open /usr/local/lib64/libverticaodbc.so failed
attempt to open /usr/local/lib64/libverticaodbc.a failed
attempt to open /lib64/libverticaodbc.so failed
attempt to open /lib64/libverticaodbc.a failed
attempt to open /usr/lib64/libverticaodbc.so failed
attempt to open /usr/lib64/libverticaodbc.a failed
attempt to open /usr/x86_64-redhat-linux/lib/libverticaodbc.so failed
attempt to open /usr/x86_64-redhat-linux/lib/libverticaodbc.a failed
attempt to open /usr/lib64/libverticaodbc.so failed
attempt to open /usr/lib64/libverticaodbc.a failed
attempt to open /usr/local/lib/libverticaodbc.so failed
attempt to open /usr/local/lib/libverticaodbc.a failed
attempt to open /lib/libverticaodbc.so failed
attempt to open /lib/libverticaodbc.a failed
attempt to open /usr/lib/libverticaodbc.so failed
attempt to open /usr/lib/libverticaodbc.a failed
ld: cannot find -lverticaodbc
ldverticaodbc中找不到/opt/vertica/lib64

有人可以提供一些线索吗?非常感谢!

最佳答案

ld是静态linkerld.sodynamic linker(而ldconfigldd与动态链接器相关)。

您需要在链接时将-L/opt/vertica/lib64/添加到ld参数中(通常应与gccg++链接)。实际上,这意味着编辑构建基础架构-例如您的Makefile-添加几十个字符。

参见ld.so(8)ldd(1)ld(1)ldconfig(8)

另请阅读Drepper's paper: How To Write Shared LibrariesProgram Library HowToLevine's book: Linkers and Loaders

关于c - 为什么ld无法从/etc/ld.so.conf中的路径找到库?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27223686/

10-12 01:19