Skip to content
Advertisement

Dynamically loading shared objects with/without version numbers

In a Linux program, I need to load a shared object called libfoobar. On my system, there’s libfoobar.so, libfoobar.so.0 and libfoobar.so.0.0.0. On another system with a different distribution installed, libfoobar.so does not exist, only the other two variants are available.

What is the correct filename I should be using when loading the shared object? Is it sufficient to try to load libfoobar.so.0 on any system and bail out if that fails, or should I attempt to load the other variants?

Advertisement

Answer

libfoobar.so.0 and libfoobar.so.0.0.0 are supposed to be symlinks which at some level point to libfoobar.so. If you found a system where only those symlinks exist but not libfoobar.so, then the installation is broken on that system.

Besides that, it is up to you whether you want to use the symlink or the original filename.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement