未找到/usr/local/lib 中的共享库 [英] Shared library in /usr/local/lib not found

查看:51
本文介绍了未找到/usr/local/lib 中的共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白.我通常将第三方软件安装到 /usr/local 中,因此库安装到/usr/local/lib 并且链接到这些库时从来没有问题.但是现在它突然不再起作用了:

I don't get it. I usually install third party software into /usr/local so libraries are installed into /usr/local/lib and never had problems linking to these libraries. But now it suddenly no longer works:

$ gcc -lkaytils -o test test.c
/usr/bin/ld.gold.real: error: cannot find -lkaytils
/usr/bin/ld.gold.real: /tmp/ccXwCkYk.o: in function main:test.c(.text+0x15):
error: undefined reference to 'strCreate'
collect2: ld returned 1 exit status

当我添加参数 -L/usr/local/lib 时,它会起作用,但我以前从未使用过它./usr/local/include中的头文件是在没有添加-I/usr/local/include的情况下找到的.

When I add the parameter -L/usr/local/lib than it works but I never had to use this before. Header files in /usr/local/include are found without adding -I/usr/local/include.

我正在使用 Debian GNU/Linux 6 (Squeeze),它在 /etc/ld.so.conf.d/libc 中有一个 /usr/local/lib 条目.conf 默认情况下,ldconfig 缓存知道我正在尝试使用的库:

I'm using Debian GNU/Linux 6 (Squeeze) which has an entry for /usr/local/lib in /etc/ld.so.conf.d/libc.conf by default and the ldconfig cache knows the library I'm trying to use:

k@vincent:~$ ldconfig -p | grep kaytils
        libkaytils.so.0 (libc6,x86-64) => /usr/local/lib/libkaytils.so.0
        libkaytils.so (libc6,x86-64) => /usr/local/lib/libkaytils.so

那么这里到底发生了什么?我在哪里可以检查 gcc 默认搜索哪些库路径?也许那里有问题.

So what the heck is going on here? Where can I check which library paths are searched by gcc by default? Maybe something is wrong there.

推荐答案

gcc -print-search-dirs 会告诉你编译器检查的路径./usr/local/lib 根本不在其中,因此您的编译时链接器(在这种情况下是来自 binutils 的新黄金 ld)找不到库,而动态链接器(ld-linux.so 读取由ldconfig) 确实如此.大概是您之前完成的构建在其 makefile 中根据需要添加了 -L/usr/local/lib(通常由 ./configure 脚本完成),或者您安装了二进制文件.

gcc -print-search-dirs will tell you what path the compiler checks. /usr/local/lib is simply not among them, so your compile time linker (in this case the new gold ld from binutils) doesn't find the library while the dynamic one (ld-linux.so which reads the cache written by ldconfig) does. Presumably the builds you've done previously added -L/usr/local/lib as necessary in their makefiles (usually done by a ./configure script), or you installed binaries.

这篇关于未找到/usr/local/lib 中的共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆