Linux程序在运行时找不到共享库
我正在尝试编译一个linux程序id3v2,它说找不到合适的库:
id3v2: error while loading shared libraries: libid3-3.8.so.3: cannot open shared object file: No such file or directory
我猜这是拉入liid3库的部分?
该文件确实存在,但是,他们正在寻找的实际上是指向以下内容的符号链接:
“同上3-3.8.so.3.0.0”
我想知道这是否是一个无法跟踪符号链接的问题?如果我知道要在哪里更改它,也许我可以手动更改它以查找 0.0。
我很乐意澄清任何细节。
看起来包含是通过以下方式完成的:
id3v2: convert.o list.o id3v2.o genre.o
${CXX} ${LDFLAGS} -pedantic -Wall -g -o $@ $^ -lz -lid3
我能够使用 Simon 的建议来找出人们可能需要图书馆的多个位置。我创建了一个符号链接,其中程序链接到实际文件。
谢谢西蒙!
I'm trying to compile a linux program, id3v2, and it says it is can't find the appropriate library:
id3v2: error while loading shared libraries: libid3-3.8.so.3: cannot open shared object file: No such file or directory
I'm guessing that this is the part that pulls in the lidid3 library?
The file DOES exist, however, what they are looking for is actually a symbolic link to:
"ibid3-3.8.so.3.0.0"
I'm wondering if it is an issue with it not being able to follow symbolic links? Perhaps I could manually change it to look for 0.0 if I knew where I was looking to change it.
I'm happy to clarify any details.
It looks like the includes are done in the following manner:
id3v2: convert.o list.o id3v2.o genre.o
${CXX} ${LDFLAGS} -pedantic -Wall -g -o $@ $^ -lz -lid3
I was able to use Simon's advice to figure out that there were multiple spots where one might expect a library. I create a symbolic link where the program was linking to the ACTUAL file.
Thank you Simon!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只要它们跟踪的最终目标存在并且可访问,库上的符号链接就可以正常工作。
您已经构建了一个动态链接的可执行文件,希望在执行时链接到 libid3-3.8.so.3。这可能在构建阶段与
-L/path/to/libid3/directory -lid3
之类的内容相关联。libid3可用,通常按优先顺序降序排列(因为您没有提到文件在哪里,我只能笼统地说):
指向
/etc/ld.so.conf
中列出的目录中libid3*
的符号链接(或/lib
或/usr/ lib
)libid3*
复制到/etc/ld.so.conf
中列出的目录(或/lib
或/usr/lib
) (默认)libid3*
的目录添加到/etc/ld.so.conf
LD_LIBRARY_PATH=/directory /path/to/libid3*
在运行 id3v2 可执行文件之前。id3v2
。 (它会起作用,但不必打扰。)在前 3 步中的任何一个之后,重新运行 ldconfig 以便更新链接器缓存。 (然后您可以运行 ldconfig -v 来验证它是否可解析。)
请注意,这些不是步骤,而是选项。您只需执行其中 1 项即可。
很高兴你更新了标题。
#include
指令与链接无关。Symlinks on libraries work fine, as long as the final target they trace to exists and is accessible.
You have built a dynamically-linked executable, that wishes to be linked against libid3-3.8.so.3 at execution time. This was likely linked during the build phase with something like
-L/path/to/libid3/directory -lid3
.You have a few options to make
libid3
available, in generally decreasing order of preference (since you didn't mention where the file was, I can only be general):libid3*
in a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
)libid3*
to a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
) (defaults)libid3*
to/etc/ld.so.conf
LD_LIBRARY_PATH=/directory/path/to/libid3*
before running your id3v2 executable.id3v2
statically. (It will work, but don't bother.)After any of the first 3, rerun
ldconfig
so the linker cache is updated. (You can then runldconfig -v
to verify it's resolvable.)Note those aren't steps, they're options. You only need to do 1 of them.
Glad you updated the title.
#include
directives have nothing to do with linking.我遇到了与您相同的错误,在阅读了此处提到的解决方案后,我用以下方法解决了该问题(在 Ubuntu 8 上):
I got the same error you did, and after reading the solutions mentioned here, I resolved the problem (on Ubuntu 8) with:
这解决了问题,只需将
/usr/local/lib
添加到/etc/ld.so.conf
(除非它已经在那里;只放一次),然后运行ldconfig。This solved the issue just add
/usr/local/lib
to/etc/ld.so.conf
(unless it's already in there; only put it once), then runldconfig
.