I have been provided a shared library file from a third party (call it libfoo.so
that I would like to link into my application. I do not have the source code for libfoo.so
, only its associated C++ headers and the resulting binary provided by the third party. libfoo.so
has a few shared library dependencies, most notably a few Boost libraries, such as libboost_thread.so.1.48
. Other than that, the dependency list is fairly thin (essentially just libstdc++.so.6
).
Here's the catch: my application, which uses Boost heavily, is built against a newer version, v1.55. Therefore, if I try to link my application against the v1.55 libraries that it needs as well as the v1.48 libraries that libfoo.so
pulls in, I'm bound to run into problems with duplicate symbols; that's a non-starter. I could probably roll my application back to v1.48 with a little work, but I'd like to prevent this one dependency from holding me back from changing Boost versions in the future.
Is there some kind of intermediate product that I could create that sits between libfoo.so
and my application that would decouple the Boost dependencies from each other? I found a number of similar SO questions, but none that I could find that captured this particular situation; it's not Boost-specific per se, but instead relates to devising a way to link together multiple ABI-incompatible shared library versions into a single application.
One rough idea that I came up with (which I'm not sure is even possible): would it be possible to create a wrapper library that sits around libfoo.so
and resolves all of its dependencies statically? If there was a way that I could take libfoo.so
and the various shared libraries that it links to and create a static library, say libfoowrapper.a
, I could link that into my application directly (with the caveat that I'm careful not to leak any Boost stuff into the wrapper library's interface, to guard against ABI incompatibilities with the two versions).
Is there any way to accomplish something like this? At first, I'm operating on Unix-like platforms using gcc
(Linux, MacOS); Windows (using Visual Studio) could be in the future.