Boost header-only dependencies on serialization

boost:bimap and boost::graph should be header-only libraries, i.e. you are supposed to be able to use them by just including the corresponding header file, with no need to link in any compiled library.

Actually with the latest boost version (1.44) some binary dependencies on boost::serialization appear, which result in link errors similar to (on Windows):

LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc90-mt-gd-1_44.lib'

This shouldn’t be, as the serialization library is an optional dependency of bimap. The solution theoretically is to define the appropriate macros to exclude serialization support:

#define BOOST_BIMAP_DISABLE_SERIALIZATION

before #including <boost/bimap.hpp>, and:

#define BOOST_MULTI_INDEX_DISABLE_SERIALIZATION

before #including <boost/graph/depth_first_search.hpp>.

But there are bugs so currently you need to manually patch the files mentioned in that bug report:

  • bimap/detail/set_view_iterator.hpp
  • bimap/detail/map_view_iterator.hpp
  • bimap/relation/mutant_relation.hpp

by wrapping the include directive as follows:

#ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
#include <boost/serialization/nvp.hpp>
#endif // BOOST_BIMAP_DISABLE_SERIALIZATION

There may be more dependencies; the way to troubleshoot those at compile time (at link time it’s impossible since the linker error messages are not helpful) is to temporarily rename boost/serialization to boost/serialization_1 – this will cause compiler errors whenever the nvp header is included notwithstanding the BOOST_XXXXX_DISABLE_SERIALIZATION directives.

About paolog

homo technologicus cynicus
This entry was posted in C, Howtos. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: