Boost logo

Boost :

Subject: [boost] [1.44][serialization] Link error with polymorphic archives and BOOST_CLASS_EXPORT
From: Ralph Tandetzky (ralph.tandetzky_at_[hidden])
Date: 2011-08-12 13:41:09


Hi,

I discovered a problem, that has been previously discussed in a post
from 2011-01-21 which has the same title. No concluding answer was given
there, so I post the problem again. Essentially, the following code
compiles but doesn't link:

--------------------------
#include <sstream>

#include <boost/serialization/export.hpp>
#include <boost/archive/polymorphic_binary_oarchive.hpp>

class A {
public:
     template<class Archive>
     void serialize(Archive & ar, const unsigned version)
     {
     }
};

BOOST_CLASS_EXPORT(A)

int main()
{
     A a;

     std::ostringstream os;
     boost::archive::polymorphic_binary_oarchive oa(os);
     oa & a;
}
--------------------------

Removing the line with "BOOST_CLASS_EXPORT(A)" or turning the
"polymorphic_binary_oarchive" into a
"binary_oarchive" removes the linker error. With Visual Studio 10 the
following error message occurs:

main.obj : error LNK2001: unresolved external symbol "public: static
void __cdecl boost::archive::detail::archive_serializer_map<class
boost::archive::detail::polymorphic_oarchive_route<class
boost::archive::binary_oarchive_impl<class
boost::archive::binary_oarchive,char,struct std::char_traits<char> > >
>::erase(class boost::archive::detail::basic_serializer const *)"
(?erase@?$archive_serializer_map_at_V?$polymorphic_oarchive_route_at_V?$binary_oarchive_impl_at_Vbinary_oarchive_at_archive@boost@@DU?$char_traits_at_D@std@@@archive_at_boost@@@detail_at_archive@boost@@@detail_at_archive@boost@@SAXPBVbasic_serializer_at_234@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: static
bool __cdecl boost::archive::detail::archive_serializer_map<class
boost::archive::detail::polymorphic_oarchive_route<class
boost::archive::binary_oarchive_impl<class
boost::archive::binary_oarchive,char,struct std::char_traits<char> > >
>::insert(class boost::archive::detail::basic_serializer const *)"
(?insert@?$archive_serializer_map_at_V?$polymorphic_oarchive_route_at_V?$binary_oarchive_impl_at_Vbinary_oarchive_at_archive@boost@@DU?$char_traits_at_D@std@@@archive_at_boost@@@detail_at_archive@boost@@@detail_at_archive@boost@@SA_NPBVbasic_serializer_at_234@@Z)

Is there something wrong with the serialization library?

Regards,
Ralph Tandetzky.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk