Boost logo

Boost Users :

Subject: Re: [Boost-users] unwanted exported symbols in a DLL which statically links to Boost.Library
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-04-22 13:05:00


> so i wonder where those symbols above comes from?

The serialization library contains code which most optomisers will
discard as it is not explicitly referenced. This was discovered when
applications built and tested with "debug" failed when built with "release".
The solution was to add "export" declarations to these functions so that
the optimiser wouldn't discard them.

> Anyone could help
> me to remove from the DLL exporting section those unwanted symbols?

This is implemented by "force_include.hpp". If you alter this header
so that the defines don't do anything, you might be able to eliminate
the exported symbols, but I wouldn't expect the library to work
when compiled in release mode.

Good Luck

Robert Ramey

Luca Cappa wrote:
> Hello,
>
> I am creating a DLL using the VisualC++ 8sp1, which statically links
> to Boost.Library, and also to another static library, which links to
> Boost.Library statically too.
>
> In the export section of the built DLL I see, among the few public
> functions which it should export, hundreds of exported functions like
> the ones below. I would really like to export the symbols the DLL
> defines as exported, and not anything else which is unexpectly
> exported, like the ones shown below:
>
> boost::archive::detail::oserializer<class
> boost::archive::xml_oarchive,struct sqy::Vector2<float>
>>>> oserializer<class boost::archive::xml_oarchive,struct
>>>> sqy::Vector2<float> >(void)
>
> boost::archive::detail::oserializer<class
> boost::archive::xml_oarchive,struct sqy::Vector2<float>
>>>> oserializer<class boost::archive::xml_oarchive,struct
>>>> sqy::Vector2<float> >(void)
>
> boost::archive::detail::oserializer<class
> boost::archive::xml_oarchive,struct sqy::Vector2<double>
>>>> oserializer<class boost::archive::xml_oarchive,struct
>>>> sqy::Vector2<double> >(void)
>
>
> In my static library, which statically link to the Boost.Serialization
> library, I have the following code which explicitly instantiate some
> template type on a set of a priori known datatypes:
>
> template MYLIB_API struct sqy::Vector2<int>;
> template MYLIB_API struct sqy::Vector2<float>;
> template MYLIB_API struct sqy::Vector2<double>;
> template MYLIB_API struct sqy::Vector2<size_t>;
>
> #define INSTANTIATE_VECTOR2_SERIALIZATION(x)\
> template void MYLIB_API
> Vector2<x>::serialize<boost::archive::xml_oarchive> (\
> boost::archive::xml_oarchive&, const unsigned int);\
> template void MYLIB_API
> Vector2<x>::serialize<boost::archive::xml_iarchive> (\
> boost::archive::xml_iarchive&, const unsigned int);
>
> INSTANTIATE_VECTOR2_SERIALIZATION(int);
> INSTANTIATE_VECTOR2_SERIALIZATION(float);
> INSTANTIATE_VECTOR2_SERIALIZATION(double);
> INSTANTIATE_VECTOR2_SERIALIZATION(size_t);
>
> Notice that, when the DLL is created, MYLIB_API is defined like
>
> # define MYLIB_API
>
> so i wonder where those symbols above comes from? Anyone could help
> me to remove from the DLL exporting section those unwanted symbols?
>
> Many thanks in advance,
> Luca


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