为什么不能从/etc/ld.so.conf中的路径找到库?

时间:2014-12-01 07:36:55

标签: c linux gcc linker ld

我想将/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
    ......

但是当我跑#34; 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

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

1 个答案:

答案 0 :(得分:1)

ld静态 linkerld.sodynamic linkerldconfig& ldd与动态链接器相关。)

您需要在链接时将-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 HowTo& Levine's book: Linkers and Loaders