I'm trying to build FileZilla on Linux and have my binary run without needing the hack of having LD_LIBRARY_PATH
set in the terminal. I've got the current directory structure:
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
I've been putting the appropriate libraries into lib
one by one, based on what's listed here:
$ 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]
However, when I now try to run the binary I get the following:
$ ./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
Why can't it find libwx_gtk3u_html-3.2.so.0
? It's in the lib
directory. And why does it even require that file when it's not apparently required in the ELF? Can it be pulled in by another SO file?
Turns out my libraries weren't looking for their required libraries in the same directory because they had no RUNPATH
set. I had to set it to look in the origin directory like so, and then they loaded properly:
patchelf --set-rpath "\$ORIGIN" ./libwx_gtk3u_xrc-3.2.so.0