Compiled libraries are automatically loaded, when a binary is executed. For this, the locations defined in /etc/ld.so.conf are checked. On most distributions you should put the library in /usr/local/lib
, where libraries not installed by the package manager are stored.
If you don't want to install the library system wide (or don't have root access), you can set LD_LIBRARY_PATH
to the folder containing your .so-file when running your program:
LD_LIBRARY_PATH=/path/to/folder_with_so_file ./yourprogram
Regarding the version number: if your program explicitly looks for .so
without a number, create a symlink (also in the lib folder):
ln -s <name>.so.0 name.so
Most libraries keep the file with the most specific version number and create symlinks for the major version and the non-versioned name (for example on my system /usr/lib
contains the files libjpeg.so
, /usr/lib64/libjpeg.so.62
and /usr/lib64/libjpeg.so.62.0.0
, the former two being symlinks to the latter)