Kenneth Riddile wrote:
I have a custom input archive type that has worked fine when statically linked to the serialization library. I'm now must use serialization as a DLL and the code no longer compiles. This is under MSVC9 with BOOST_ALL_DYN_LINK defined. This code works fine on Linux/GCC with serialization built as a shared library...so the problem appears specific to Windows/MSVC. Here is a boiled down version of the code that exhibits the problem:
// HEADER CONTENTS #include
class CustomArchive : public boost::archive::xml_iarchive_impl<CustomArchive> , public boost::archive::detail::shared_ptr_helper { public: CustomArchive( std::istream& is, int foo ) : boost::archive::xml_iarchive_impl<CustomArchive>( is, 0 ) , m_foo( foo ) {
}
int GetFoo() const { return m_foo; }
template<class T> void load( T& t ) { boost::archive::xml_iarchive_impl<CustomArchive>::load( t ); }
private: friend class boost::archive::xml_iarchive_impl<CustomArchive>; friend class boost::archive::basic_xml_iarchive<CustomArchive>; friend class boost::archive::load_access;
int m_foo; };
// CPP CONTENTS #include
#include #include #include namespace boost { namespace archive { template class basic_xml_iarchive<CustomArchive>; template class xml_iarchive_impl<CustomArchive>; template class detail::archive_serializer_map<CustomArchive>; } }
BOOST_SERIALIZATION_REGISTER_ARCHIVE( CustomArchive )
and here are the errors:
1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(41) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_start' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(77) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_end' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(83) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(89) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(95) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(101) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(108) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::basic_xml_iarchive' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/basic_xml_iarchive.ipp(111) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::~basic_xml_iarchive' : definition of dllimport function not allowed 1>Warning: This header is deprecated. Please use: boost/spirit/include/classic_rule.hpp 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(83) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::load' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(114) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::load' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(127) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::load' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(140) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::load' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(153) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::load_override' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(162) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::init' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(189) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::xml_iarchive_impl' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/xml_iarchive_impl.ipp(202) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::~xml_iarchive_impl'
definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/archive_serializer_map.ipp(45) : error C2491: 'boost::archive::detail::archive_serializer_map<Archive>::insert' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/archive_serializer_map.ipp(57) : error C2491: 'boost::archive::detail::archive_serializer_map<Archive>::erase' : definition of dllimport function not allowed 1>C:\Boost\include\boost/archive/impl/archive_serializer_map.ipp(67) : error C2491: 'boost::archive::detail::archive_serializer_map<Archive>::find' : definition of dllimport function not allowed