我正在尝试在 Linux 上构建 FileZilla 并运行我的二进制文件,而无需在终端中设置
LD_LIBRARY_PATH
。 我已经得到了当前的目录结构:
FileZilla3
├── bin
│ ├── filezilla
│ ├── fzputtygen
│ ├── fzsftp
│ └── fzstorj
└── lib
├── libfilezilla.so.45
├── libfzclient-commonui-private-3.67.1.so
├── libfzclient-private-3.67.1.so
├── libgmp.so.10
├── libgnutls.so.30
├── libhogweed.so.6
├── libnettle.so.8
├── libsqlite3.so.0
├── libwx_baseu-3.2.so.0
├── libwx_baseu_xml-3.2.so.0
├── libwx_gtk3u_aui-3.2.so.0
├── libwx_gtk3u_core-3.2.so.0
├── libwx_gtk3u_html-3.2.so.0
└── libwx_gtk3u_xrc-3.2.so.0
我已经根据此处列出的内容将适当的库一一放入
lib
中:
$ eu-readelf -d filezilla
Dynamic segment contains 47 entries:
Addr: 0x00000000004ed2d0 Offset: 0x4ec2d0 Link to section: [36] '.dynstr'
Type Value
NEEDED Shared library: [libfzclient-commonui-private-3.67.1.so]
NEEDED Shared library: [libfzclient-private-3.67.1.so]
NEEDED Shared library: [libfilezilla.so.45]
NEEDED Shared library: [libpugixml.so.1]
NEEDED Shared library: [libdbus-1.so.3]
NEEDED Shared library: [libwx_gtk3u_aui-3.2.so.0]
NEEDED Shared library: [libwx_gtk3u_xrc-3.2.so.0]
NEEDED Shared library: [libwx_gtk3u_core-3.2.so.0]
NEEDED Shared library: [libwx_baseu-3.2.so.0]
NEEDED Shared library: [libsqlite3.so.0]
NEEDED Shared library: [libgtk-3.so.0]
NEEDED Shared library: [libgdk-3.so.0]
NEEDED Shared library: [libstdc++.so.6]
NEEDED Shared library: [libm.so.6]
NEEDED Shared library: [libgcc_s.so.1]
NEEDED Shared library: [libc.so.6]
RUNPATH Library runpath: [$ORIGIN/../lib]
但是,当我现在尝试运行二进制文件时,我得到以下信息:
$ ./bin/filezilla
./bin/filezilla: error while loading shared libraries: libwx_gtk3u_html-3.2.so.0: cannot open shared object file: No such file or directory
为什么找不到
libwx_gtk3u_html-3.2.so.0
? 它位于 lib
目录中。 当 ELF 中显然不需要该文件时,为什么它甚至需要该文件? 可以被另一个SO文件拉入吗?
结果我的库没有在同一目录中寻找所需的库,因为它们没有设置
RUNPATH
。 我必须将其设置为在原始目录中查找,如下所示,然后它们正确加载:
patchelf --set-rpath "\$ORIGIN" ./libwx_gtk3u_xrc-3.2.so.0