You cannot link two libraries with identical symbols and get access to both. However, you can build your own thin wrapper libraries to disambiguate the two versioned libraries:
- Define an abstract class
Wrapper that exercises the functions of the target library using abstract virtual functions
- Define an implementation of
Wrapper in a class called WrapperImpl that calls through to the target library from the virtual methods
- Define a free-standing method
Wrapper *MakeImpl returning new WrapperImpl()
- Compile
WrapperImpl into static libraries several times, linking with different versions of the target library each time. Critical: pass -DWrapperImpl=WrapperImplV1 -DMakeImpl=MakeImplV1 to the compiler, with V1, V2, V3, and so on, for different versions. You should end up with multiple libraries.
- Link your main tester with these multiple libraries
At this point, your main tester has access to free-standing functions MakeImplV1, MakeImplV2, MakeImplV3 and so on created through renaming MakeImpl through the preprocessor. Use these functions to obtain instances of Wrapper that call through to different versions of the target library.