I have two libraries, for example two toaster libraries libtoaster_a.so and libtoaster_b.so and all the associated major/minor/rev symlinks eg libtoaster_a.so.1.0.0 etc. Both libraries implement the same toaster interface, but simply do the processing differently. Hence when I build an application that uses the library it doesn't matter which is used (from the applications perspective they are the same).
Because I would like to decide which library to use after the application has been compiled and distributed I make a symbolic link libtoaster.so which points to libtoaster.so.1 which can then point to either libtoaster_a.so.1 and libtoaster_b.so.1. Hence the user/installer could simply change the libtoaster.so.1 link to choose the implementation to use.
For the build say I have libtoaster.so.1 linked to libtoaster_a.so.1 by default. when I compile my application eg: my_app by something like gcc -o my_app -ltoaster...
it compiles and even runs with libtoaster_a.so.1 correctly. However if I run ldd on my_app I will see it is linked to libtoaster_a.so.1 rather than libtoaster.so.1 as desired, hence changing the libtoaster.so.1 link has no effect.
Is there a nicer way to fix this than making libtoaster_a.so.1, renaming it to libtoaster.so.1, making my_app against this library then deleting libtoaster.so.1 and creating it as a symbolic link again?