how to build boost serialization library

Rico-E picture Rico-E · Jan 15, 2014 · Viewed 9.7k times · Source

I read somewhere that the serialization library of boost has to be compiled (I forgot where I read it, otherwise I would have posted a link).

So I downloaded the latest release from source forge and extracted it to a path in my project. And now?

I investigated the folder, but I couldn't find a makefile.

So what do I have to do, to compile the boost:serialization lib?

Edit: nevertheless I tried to work with it, without compiling it, but I get this error:

boost/archive/basic_xml_oarchive.hpp:92:9: error: 
no matching function for call to 'assertion_failed'
    BOOST_MPL_ASSERT((serialization::is_wrapper< T >));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So I think the reason for this is, that it wasn't compiled. Is that right?

Answer

JBentley picture JBentley · Jan 15, 2014

To build Boost, follow the instructions here.

As per your comment, you want to build just a part of Boost (serialization). If you follow the above link, there is a section containing the following advice (wording might vary, I've copied it from the Windows instructions):

For a description of other options you can pass when invoking b2, type:

b2 --help

In particular, to limit the amount of time spent building, you may be interested in:

  • reviewing the list of library names with --show-libraries
  • limiting which libraries get built with the --with-library-name or --without-library-name options

Typing b2 --show-libraries yields the following:

The following libraries require building:
    - atomic
    - chrono
    - context
    - coroutine
    - date_time
    - exception
    - filesystem
    - graph
    - graph_parallel
    - iostreams
    - locale
    - log
    - math
    - mpi
    - program_options
    - python
    - random
    - regex
    - serialization
    - signals
    - system
    - test
    - thread
    - timer
    - wave

So, to build just serialization, pass the option --with-serialization to b2 e.g. to build all library types (static/dynamic library, static/dynamic runtime, debug/release, single/multithreading) using VS2013 you could type this:

b2 toolset=msvc-12.0 --with-serialization --build-type=complete stage

Note, if you plan to make use of Boost in future projects, it may be simpler to just build the entire thing (i.e. omitting the --with-serialization option) so that all libraries are ready to use straight away whenever you need them.