Reputation: 1617
I'm building my program on my computer, on which libtiff.so -> libtiff.so.5
.
And then pushing the builds on another machine on which libtiff.so -> libtiff.so.4
.
At runtime, my program exists : « error while loading shared libraries: libtiff.so.5
: cannot open shared object file: No such file or directory ».
I cannot upgrade the other machine, and I would like to avoid compiling on a virtual machine (with the same linux version than the executing machine). Therefore, I would like to force the compiler to use the libtiff.so.4
instead of libtiff.so.5
.
I have libtiff.so.4
installed on my computer (as well as libtiff.so.5
). How can I force the linkage with this version instead of the newer version. I thought about moving the libtiff.so -> libtiff.so.4
, but I'm afraid of breaking my system if it needs the latest version (apt-get purge libtiff5
gives an error because some other package needs it).
Is it possible to link with an older (installed) version of a library? If yes, how?
And is it harmfull to change the symbolic link of libtiff.so
to the older version? If not, will it solve my issue?
Upvotes: 7
Views: 5457
Reputation: 1
You see that error when application is running. So you can either stop your application and then exrract your library tar file. Or, force to link the lib file to the newer version after you extract. In second case, you will use something like:
ln -fs libversionname libfile
Example:
ln -fs libomyapp.1.1.3 libomyapp.lib
This links your libomyapp.lib
to the version specified. This can be your older vsersion or your newer version.
But as said, best way to work is to bring down your application to properly match to the expected lib functionality to work without errors or issues.
Upvotes: 0
Reputation: 51910
You can use this syntax to link to a specific version of a library:
gcc [other options] -l:libtiff.so.4
You do not need to specify a path; the usual directories are searched in order to find the library.
Note: as Michael Wild mentioned, you should have the header files for that version installed instead of the newest ones.
Upvotes: 4
Reputation: 26381
As others have mentioned, you can force the linker by specifying the full versioned name, or even the absolute path.
However, I would strongly advice against doing so. The problem is, that the installed headers correspond to the newer version of the library. If there have been API/ABI-breaking changes between these library versions, the program might work, crash intermittently, or if you're lucky, not work at all.
Instead you should temporarily install the development package that corresponds to the libtiff.so.4 library. If on Debian/Ubuntu or similar, this would be the libtiff4-dev
package.
Upvotes: 2
Reputation: 136495
Specify the full path to the .so: instead of -ltiff
pass /lib64/libtiff.so.4
to the linker.
Upvotes: 0