Dynamically load shared objects using dlopen ()

I am working on a simple X11 application.

By default, my application requires only libX11.so and the standard gcc C and math libs. The application can expand the functions with the help of Xfixes, Xrender and ALSA sound system. However, these features (Xfixes, Xrender, and ALSA) are optional.

To achieve this, I use runtime loading, i.e. libXfixes, libXrender and libasound must be dlopen () ed.

Therefore, an application may function in the absence of such libraries.

Now my question is:

What library names should I use when calling dlopen()?  

I noticed that they differ from distribution to distribution. For example, on openSUSE 11 they are called the following:

  • libXfixes.so
  • libXrender.so
  • libasound.so

In Ubuntu, however, names have an attached version number, for example:

  • libXfixes.so.3
  • libXrender.so.1
  • libasound.so.2

"libXfixes.so" Ubuntu, , , lib. . , ?
/usr/lib/first , , libs, ? - ?

, ,

+5
2

dlopen, SONAME. , readelf -d [libname].

, Fedora Linux SONAME C libc.so.6.

.so .so.6 . .

, API.

+1

, , dlopen() () "libXfixes.so", , , "libXfixes.so.3" ,

$ file /usr/lib/libalpm.so
/usr/lib/libalpm.so: symbolic link to `libalpm.so.4.0.3'

"/usr/lib/" , ".X" , , .

, libXfixes.so.2, .

-1

All Articles