我想将/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
ld
从verticaodbc
中找不到/opt/vertica/lib64
。有人可以提供一些线索吗?非常感谢!
最佳答案
ld
是静态linker。 ld.so
是dynamic linker(而ldconfig
和ldd
与动态链接器相关)。
您需要在链接时将-L/opt/vertica/lib64/
添加到ld
参数中(通常应与gcc
或g++
链接)。实际上,这意味着编辑构建基础架构-例如您的Makefile
-添加几十个字符。
参见ld.so(8),ldd(1),ld(1),ldconfig(8)
另请阅读Drepper's paper: How To Write Shared Libraries,Program Library HowTo和Levine's book: Linkers and Loaders
关于c - 为什么ld无法从/etc/ld.so.conf中的路径找到库?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27223686/