You cannot link two libraries with the same symbols and access both. However, you can create your own thin shell libraries to eliminate two versions of the libraries:
- Define an abstract
Wrapper class that acts as a target library using abstract virtual functions - Define a
Wrapper implementation in a class called WrapperImpl that accesses the target library from virtual methods - Define a standalone
Wrapper *MakeImpl return new WrapperImpl() - Compile
WrapperImpl into static libraries several times, each time linking them to different versions of the target library. Critical: pass -DWrapperImpl=WrapperImplV1 -DMakeImpl=MakeImplV1 compiler with V1 , V2 , V3 , etc. for different versions. You must have several libraries. - Link your core tester to these several libraries
At this point, your main tester has access to the stand-alone functions MakeImplV1 , MakeImplV2 , MakeImplV3 , etc., created by renaming MakeImpl through a preprocessor. Use these functions to obtain instances of Wrapper that migrate to different versions of the target library.
source share