gpt4 book ai didi

c - 为什么 ld 无法从/etc/ld.so.conf 中的路径找到库?

转载 作者:太空狗 更新时间:2023-10-29 12:31:00 32 4
gpt4 key购买 nike

我想将/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 没有从 /opt/vertica/lib64 中找到 verticaodbc

谁能提供一些线索?非常感谢!

最佳答案

ldstatic linker . ld.sodynamic linker (ldconfig & ldd 与动态链接器有关)。

您需要在 link 时将 -L/opt/vertica/lib64/ 添加到您的 ld 参数(并且您通常应该链接使用 gccg++)。实际上,这意味着编辑您的构建基础设施 - 例如您的 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com