Can Boost serialization be used as a header-only library?

Below is a minimal example of using the large Boost.Serialization library .

In order to compile a library, I need to link against the precompiled library boost_serialization

.

$ c++ -std=c++11 example.cpp -o example.x -lboost_serialization
                                          ^^^^^^^^^^^^^^^^^^^^^

      

The library is heavily shaded, although the complex inner code (function body) is pretty simple. There are only a few links that need to be referenced, namely:

boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::ostream&, unsigned int)
boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::text_iarchive_impl(std::istream&, unsigned int)
boost::archive::text_iarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()
boost::archive::text_iarchive_impl<boost::archive::text_iarchive>::~text_iarchive_impl()
...
boost::archive::archive_exception::~archive_exception()'

      

Is there a chance the library can be used without reference as a header-only library?

For example, some undocumented trick or hack?

This would make it easier to use in some supercomputing clusters and environments where it is not easy to compile Boost.

#include<sstream>
#include<numeric>
#include<boost/archive/text_oarchive.hpp> // needs linking 
#include<boost/archive/text_iarchive.hpp>
#include<boost/serialization/vector.hpp>

int main(){

    std::vector<double> v(10); std::iota(v.begin(), v.end(), 0);
    std::stringstream ss;
    {
        boost::archive::text_oarchive toa(ss);
        toa << v;
    }
    std::vector<double> v2;
    boost::archive::text_iarchive tia(ss);
    tia >> v2;
    assert(v == v2);
}

      


EDIT : It would be really great for me if the library only allowed a header like Boost.Asio ( stackoverflow )


EDIT2 . The author and maintainer of Boost.Serialization rejected the idea of ​​creating just a header. https://github.com/boostorg/serialization/issues/71

+3
c ++ boost header-only boost-serialization


source to share


No one has answered this question yet

See similar questions:

sixteen
Boost.Asio as header only

or similar:

1643
Why templates can only be implemented in a header file?
12
Linker Errors When Using Forced Serialization
1
Boost Serialization: Linker errors in XCode 5 project generated from CMake (with minimal complete example)
1
Destroy multiple values ​​with boost :: serialize (with SSCCE)
0
How to boost: serialize a hashmap of vectors?
0
C ++ Code :: Blocks - undefined link with boost / archive for serialization
0
Speeding up Tcp-Asio-Server crash using Qt on Mac
0
undefined reference to enhance serialization features
0
Linker error: Static linking sequential sort library
-3
Boost library types



All Articles
Loading...
X
Show
Funny
Dev
Pics