Reputation: 265
I have built a library (VC10) that is dependant on multiple Boost libraries. I would like to use this library in multiple applications where each application is dependant on different Boost versions and I would like to be able to do this without building the library for each Boost version.
I have built my library using BOOST_ALL_DYN_LINK as well as using BOOST_ALL_NO_LIB but both these libraries seem to depend on a specific Boost version.
Could someone please explain how I can build a library that is dependant on Boost where it is possible to update the Boost version without recompiling or relinking the library?
Upvotes: 3
Views: 709
Reputation: 2976
"Could someone please explain how I can build a library that is dependant on Boost where it is possible to update the Boost version without recompiling or relinking the library?"
I do not think that this is possible. Any number of small changes, such as adding a new data member to a class, will require recompilation to switch between releases. It would only be possible if boost does not change any such details between releases.
If you are unable to follow @jamesj suggestion of sticking to a single version, namespaces may be able to help. I would take each boost version and modify it so instead of having boost as the top level namespace it would be boost_x_y_z where x y z gives the version number. So the following code
namespace acc = boost::accumulators;
typedef acc::features<acc::tag::density> features_t;
typedef acc::accumulator_set<double, features_t> accumulator_t;
Could target version 1.47.0 with:
namespace acc = boost_1_47_0::accumulators;
typedef acc::features<acc::tag::density> features_t;
typedef acc::accumulator_set<double, features_t> accumulator_t;
If you don't care what version you use you might put in a header somewhere:
namespace boost_latest = boost_1_50_0;
So my example would become:
namespace acc = boost_latest::accumulators;
typedef acc::features<acc::tag::density> features_t;
typedef acc::accumulator_set<double, features_t> accumulator_t;
Then when a new version comes along you just update a single definition and recompile. New versions of your library should still be ABI compatible with your old programs. But they will not take advantage of the new boost release without recompilation.
Upvotes: 1