In Linux, Consider there is test.so file. It requires other .so (for example alpha.so, beta.so, charlie.so)file during runtime. Its basically a shared library. When I run the following command in the terminal:
$ ldd test.so
following output was displayed:
alpha.1.4.so ==> usr/lib/x86-linux-gnu/alpha.1.4.so
beta.1.4.so ==> usr/lib/x86-linux-gnu/beta.1.4.so
charlie.1.4.so ==> usr/lib/x86-linux-gnu/charlie.1.4.so
I want to modify the cmake which is used for building the test.so to point to symlink, like this
alpha.so ==> usr/lib/x86-linux-gnu/alpha.1.4.so
beta.so ==> usr/lib/x86-linux-gnu/beta.1.4.so
charlie.so ==> usr/lib/x86-linux-gnu/charlie.1.4.so
rather than linking it to the specific version of that library (alpha.1.4.so
, beta1.4.so
, charlie.1.4.so
).
How can I modify my CMake configuration to make the test.so file to follow symlink rather than the specific version? I basically want to make it version independent.
The solution by @Tsyvarev will fit for dynamic library whose SO_NAME do not contains version in it.
But in my case the SO_NAME of the .so
file contains the version number in it. Though it is not recommended to have a version number in SO_NAME some library does it. I have modified the .so
file using patchelf command in linux.
patchelf --set-soname dynamic_lib.so dynamic_lib.so.version_number
This will change the SO_NAME of the library.