In my open-source project Artha I use libnotify for showing passive desktop notifications to the user.
Instead of statically linking libnotify, a lookup at runtime is made for the shared object (.so) file via dlload
, if available on the target machine, Artha exposes the notification feature in it's GUI. On app. start, a call to dlload
with filename param as libnotify.so.1
is made and if it returns a non-null pointer, then the feature is exposed.
A recurring problem with this model is that every time the version number of the library is bumped, Artha's code needs to be updated, currently libnotify.so.4
is the latest to entail such an occurance.
Is there a linux system call (irrespective of the distro the app. is running on), which can tell me if a particular library's shared object is available at runtime? I know that there exists the bruteforce option of enumerating the library by going from 1 to say 10, I find the solution ugly and inelegant.
Also, if this can be addressed via autoconf, then that solution is welcome too I.e. at build time, based on the target machine, the configure.h generated should've the right .so name that can be passed to dlload
.
P.S.: I think good distros follow the style of creating links to libnotify.so.x
so that a programmer can just do dlload("libnotify.so", RTLD_LAZY)
and the right version numbered .so is loaded; unfortunately not all distros follow this, including Ubuntu.