Can you change a dynamic link target without recompiling

dynamic-linkingsymlink

I downloaded a program that unfortunately doesn't come as a source distribution. When I go to run it, I get the error

error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory

The program seems to have been linked against a specific version of libjpeg which my distro does not have. Creating a symlink named /usr/lib32/libjpeg.so.62 to my actual libjpeg.so fixes the problem, but poking around in /usr/lib32 just to make one program work seems stupid and over the top.

Is there any way (sans recompiling) to make the program dynamically link libjpeg.so instead of libjpeg.so.62?

FWIW, file info for the program is

ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

Best Answer

Binary-edit the file (with vim -b for instance) and replace any occurrence of /usr/lib32/libjpeg.so.62 with some path to your libjpeg.so that is exactly the same size like for instance /usr/lib//////libjpeg.so

/usr/lib32/libjpeg.so.62
/usr/lib//////libjpeg.so
Related Question