Boost logo

Boost Users :

Subject: [Boost-users] [serialization] boost::serialization adds huge amounts of exports to resultant Windows PE file
From: Matheus Peschke de Azevedo (mpeschke_at_[hidden])
Date: 2011-09-05 20:15:16


Chris,

Boost serialization defaults lots of classes/functions to be automatically
exported.
This is done in \boost\serialization\force_include.hpp:

#if defined(BOOST_HAS_DECLSPEC) && !defined(__COMO__)
# if defined(__BORLANDC__)
# define BOOST_DLLEXPORT __export
# else
# define BOOST_DLLEXPORT __declspec(dllexport)
# endif
#elif ! defined(_WIN32) && ! defined(_WIN64)
# if defined(__MWERKS__)
# define BOOST_DLLEXPORT __declspec(dllexport)
# elif defined(__GNUC__) && (__GNUC__ >= 3)
# define BOOST_USED __attribute__ ((used))
# elif defined(__IBMCPP__) && (__IBMCPP__ >= 1110)
# define BOOST_USED __attribute__ ((used))
# elif defined(__INTEL_COMPILER) && (BOOST_INTEL_CXX_VERSION >= 800)
# define BOOST_USED __attribute__ ((used))
# endif
#endif

The easiest workaround for this is:

1. Place your serialization #include lines in a precompiled header.
2. Right after all your boost serialization #includes, write this:

#ifdef BOOST_DLLEXPORT
#undef BOOST_DLLEXPORT // it was '__declspec(dllexport)'
#define BOOST_DLLEXPORT // now it's ''
#endif

Just rebuild your project and you'll see all exports gone. No need to
recompile boost serialization lib as functions affected are templates.

Regards,
Matheus


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net