3 ms·
Another fun `ldd` fact: some executables can be run, even when ldd says its libraries cannot be located. This is thanks to $ORIGIN rpaths. 1. Create an execut
by stabbles 3y ago
Another fun `ldd` fact: some executables can be run, even when ldd says its libraries cannot be located.
This is thanks to $ORIGIN rpaths.
1. Create an executable in `./bin/exe` with say `$ORIGIN/../lib` rpath, and link it to some library `./lib/libfoo.so`
2. Create a symlink one dir up: `ln -s ./bin/exe exe`
3. `ldd exe` will tell you `libfoo.so` is not found
4. `./exe` runs just fine.
This is because the kernel resolves the symlink path, and the dynamic loader receives that, and uses it for $ORIGIN.
`ldd` on the other hand will interpolate $ORIGIN with the symlink location, not its target.
This only "works" for the executable, not for dependencies of dependencies: if a library is located as a symlink in a different directory from its target, $ORIGIN is relative to the symlink, and it's likely to break.
This can be problematic if you wanna put symlinks in say `/usr/local/lib`.