Linux程序在运行时找不到共享库 [英] Linux Program can't find Shared Library at run-time
问题描述
我试图编译一个linux程序,id3v2,它说它找不到合适的库:
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
我猜这是拉动lidid3库的部分?
I'm guessing that this is the part that pulls in the lidid3 library?
文件DOES存在,但是,他们正在寻找实际上是一个符号链接:
The file DOES exist, however, what they are looking for is actually a symbolic link to:
ibid3-3.8.so.3.0.0
"ibid3-3.8.so.3.0.0"
我想知道这是否是一个问题它不能跟随符号链接?也许我可以手动改变它寻找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
使用西蒙的建议,找出有多个地方,人们可能期望一个图书馆。我创建一个符号链接,程序链接到ACTUAL文件。
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.
谢谢Simon!
推荐答案
您已经构建了一个动态链接的可执行文件,它希望链接到libid3-3.8.so。 3在执行时。这在构建阶段可能与 -L / path / to / libid3 / directory -lid3
有关。
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
.
您有一些选项可使 libid3
可用,通常按优先顺序排列(因为您没有提及文件的位置,我只能是一般的):
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 *
在/etc/ld.so.conf
(或/ lib
或/ usr / lib )
- 将
libid3 *
复制到/ etc /ld.so.conf
(或/ lib
或/ usr / lib
)默认值) - 将包含
libid3 *
的目录添加到/etc/ld.so.conf
- 在运行您的id3v2可执行文件之前,将
LD_LIBRARY_PATH = / directory / path /设置为/ libid3 *
- 静态地重新编译
id3v2
。
- Create a symlink to
libid3*
in a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
) - Copy
libid3*
to a directory listed in/etc/ld.so.conf
(or/lib
or/usr/lib
) (defaults) - Add the directory containing
libid3*
to/etc/ld.so.conf
- Set
LD_LIBRARY_PATH=/directory/path/to/libid3*
before running your id3v2 executable. - Recompile
id3v2
statically. (It will work, but don't bother.)
在任何前3个之后,重新运行 ldconfig
,以便更新链接器缓存。 (您可以运行 ldconfig -v
以验证它是否可解析。)
After any of the first 3, rerun ldconfig
so the linker cache is updated. (You can then run ldconfig -v
to verify it's resolvable.)
注意这些不是步骤, '选项。你只需要做其中的1个。
Note those aren't steps, they're options. You only need to do 1 of them.
很高兴你更新了标题。 #include
指令与链接无关。
Glad you updated the title. #include
directives have nothing to do with linking.
这篇关于Linux程序在运行时找不到共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!