|
Boost Users : |
Subject: [Boost-users] [serialization] problems extending existing archive type
From: Kenny Riddile (kfriddile_at_[hidden])
Date: 2009-06-13 21:04:51
I recently revisited a problem I was having trouble solving awhile ago,
and I'm still having issues. I wish to create a new archive type that
is simply an extension of xml_iarchive that takes an additional
construction parameter and then be able to retrieve that value from the
archive later. This new archive type is part of a static library. See
attached Archive.hpp/cpp for my most recent attempt. I should also
mention that BOOST_ALL_DYN_LINK is globally defined in my environment.
This is the cause of the errors in output1.txt. After looking at
archive/detail/decl.hpp, I was able to get my static library to compile
by defining BOOST_ARCHIVE_SOURCE while compiling the static library. I
then get the linker errors in output2.txt when trying to use the new
archive type from an executable. I'm sure I'm just missing something
simple, but I need some hand-holding here because I've been at this awhile.
Thanks,
Kenny Riddile
#ifndef RS_REPOSITORY_ARCHIVE_HPP
#define RS_REPOSITORY_ARCHIVE_HPP
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <rs/repository/RepositoryFwd.hpp>
namespace rs
{
class InputArchive : public boost::archive::xml_iarchive_impl<InputArchive>
, public boost::archive::detail::shared_ptr_helper
{
public:
InputArchive( std::istream& is );
InputArchive( std::istream& is, Repository& repository );
Repository* GetRepository() const;
template<class T>
void load( T& t )
{
boost::archive::xml_iarchive_impl<InputArchive>::load( t );
}
private:
friend class boost::archive::xml_iarchive_impl<InputArchive>;
friend class boost::archive::basic_xml_iarchive<InputArchive>;
friend class boost::archive::load_access;
Repository* m_repository;
};
typedef boost::archive::xml_oarchive OutputArchive;
} // end namespace rs
#endif // RS_REPOSITORY_ARCHIVE_HPP
#include <rs/repository/Archive.hpp>
#include <rs/repository/Repository.hpp>
namespace rs
{
InputArchive::InputArchive( std::istream& is )
: boost::archive::xml_iarchive_impl<InputArchive>( is, 0 )
, m_repository( 0 )
{
}
InputArchive::InputArchive( std::istream& is, Repository& repository )
: boost::archive::xml_iarchive_impl<InputArchive>( is, 0 )
, m_repository( &repository )
{
}
Repository* InputArchive::GetRepository() const
{
return m_repository;
}
} // end namespace rs
BOOST_SERIALIZATION_REGISTER_ARCHIVE( rs::InputArchive )
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
namespace boost
{
namespace archive
{
template class basic_xml_iarchive<rs::InputArchive>;
template class xml_iarchive_impl<rs::InputArchive>;
} // end namespace archive
} // end namespace boost
#define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES rs::InputArchive
1>------ Build started: Project: repository, Configuration: Debug Win32 ------
1>Compiling...
1>Archive.cpp
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(74) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_end' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(80) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(86) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(92) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(98) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::load_override' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/basic_xml_iarchive.ipp(105) : error C2491: 'boost::archive::basic_xml_iarchive<Archive>::basic_xml_iarchive' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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>Warning: This header is deprecated. Please use: boost/spirit/include/classic_rule.hpp
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\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:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/xml_iarchive_impl.ipp(160) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::init' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/xml_iarchive_impl.ipp(187) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::xml_iarchive_impl' : definition of dllimport function not allowed
1>C:\Documents and Settings\Administrator\My Documents\Development\development\third_party\boost\1_38_0\boost/archive/impl/xml_iarchive_impl.ipp(200) : error C2491: 'boost::archive::xml_iarchive_impl<Archive>::~xml_iarchive_impl' : definition of dllimport function not allowed
1>BinaryResourceWrapper.cpp
1>ArchiveWrapper.cpp
1>ResourceFileHandle.cpp
1>Repository.cpp
1>BinaryResource.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Development\development\build\components\libs\repository\repository.dir\Debug\BuildLog.htm"
1>repository - 16 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
1>------ Build started: Project: repository_test_repository, Configuration: Debug Win32 ------
1>Linking...
1>repository.lib(Repository.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_iserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_iserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1>repository.lib(Repository.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_oserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_oserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1>repository.lib(ArchiveWrapper.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_iserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_iserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1>repository.lib(ArchiveWrapper.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_oserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_oserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1>repository.lib(Archive.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_iserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_iserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1>repository.lib(Archive.obj) : error LNK2005: "public: bool __thiscall boost::archive::detail::basic_oserializer::serialized_as_pointer(void)const " (?serialized_as_pointer_at_basic_oserializer_at_detail@archive_at_boost@@QBE_NXZ) already defined in boost_serialization-mt-gd.lib(boost_serialization-mt-gd.dll)
1> Creating library C:\Documents and Settings\Administrator\My Documents\Development\development\build\bin\Debug\repository_test_repository.lib and object C:\Documents and Settings\Administrator\My Documents\Development\development\build\bin\Debug\repository_test_repository.exp
1>repository.obj : warning LNK4217: locally defined symbol ?load_end@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXPBD_at_Z (protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_end(char const *)) imported in function "protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_override<class TestResource>(struct boost::serialization::nvp<class TestResource> const &,int)" (??$load_override_at_VTestResource@@@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXABU?$nvp_at_VTestResource@@@serialization_at_2@H_at_Z)
1>repository.obj : warning LNK4217: locally defined symbol ?load_start@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXPBD_at_Z (protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_start(char const *)) imported in function "protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_override<class TestResource>(struct boost::serialization::nvp<class TestResource> const &,int)" (??$load_override_at_VTestResource@@@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXABU?$nvp_at_VTestResource@@@serialization_at_2@H_at_Z)
1>repository.obj : warning LNK4217: locally defined symbol ??1?$xml_iarchive_impl_at_VInputArchive@rs@@@archive_at_boost@@IAE_at_XZ (protected: __thiscall boost::archive::xml_iarchive_impl<class rs::InputArchive>::~xml_iarchive_impl<class rs::InputArchive>(void)) imported in function "public: __thiscall rs::InputArchive::~InputArchive(void)" (??1InputArchive_at_rs@@QAE_at_XZ)
1>repository.obj : warning LNK4217: locally defined symbol ?load@?$xml_iarchive_impl_at_VInputArchive@rs@@@archive_at_boost@@IAEXAAV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z (protected: void __thiscall boost::archive::xml_iarchive_impl<class rs::InputArchive>::load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)) imported in function "public: void __thiscall rs::InputArchive::load<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??$load_at_V?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@InputArchive_at_rs@@QAEXAAV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@@Z)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_xml_grammar<char>::basic_xml_grammar<char>(void)" (??0?$basic_xml_grammar_at_D@archive_at_boost@@QAE_at_XZ) referenced in function "protected: __thiscall boost::archive::xml_iarchive_impl<class boost::archive::naked_xml_iarchive>::xml_iarchive_impl<class boost::archive::naked_xml_iarchive>(class std::basic_istream<char,struct std::char_traits<char> > &,unsigned int)" (??0?$xml_iarchive_impl_at_Vnaked_xml_iarchive_at_archive@boost@@@archive_at_boost@@IAE_at_AAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@I_at_Z)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::basic_xml_grammar<char>::windup(class std::basic_istream<char,struct std::char_traits<char> > &)" (?windup@?$basic_xml_grammar_at_D@archive_at_boost@@QAEXAAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@Z) referenced in function "protected: __thiscall boost::archive::xml_iarchive_impl<class boost::archive::naked_xml_iarchive>::~xml_iarchive_impl<class boost::archive::naked_xml_iarchive>(void)" (??1?$xml_iarchive_impl_at_Vnaked_xml_iarchive_at_archive@boost@@@archive_at_boost@@IAE_at_XZ)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: bool __thiscall boost::archive::basic_xml_grammar<char>::parse_start_tag(class std::basic_istream<char,struct std::char_traits<char> > &)" (?parse_start_tag@?$basic_xml_grammar_at_D@archive_at_boost@@QAE_NAAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@Z) referenced in function "protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_start(char const *)" (?load_start@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXPBD_at_Z)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: bool __thiscall boost::archive::basic_xml_grammar<char>::parse_end_tag(class std::basic_istream<char,struct std::char_traits<char> > &)const " (?parse_end_tag@?$basic_xml_grammar_at_D@archive_at_boost@@QBE_NAAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@Z) referenced in function "protected: void __thiscall boost::archive::basic_xml_iarchive<class rs::InputArchive>::load_end(char const *)" (?load_end@?$basic_xml_iarchive_at_VInputArchive@rs@@@archive_at_boost@@IAEXPBD_at_Z)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: bool __thiscall boost::archive::basic_xml_grammar<char>::parse_string(class std::basic_istream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?parse_string@?$basic_xml_grammar_at_D@archive_at_boost@@QAE_NAAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@AAV?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@5@@Z) referenced in function "protected: void __thiscall boost::archive::xml_iarchive_impl<class rs::InputArchive>::load(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &)" (?load@?$xml_iarchive_impl_at_VInputArchive@rs@@@archive_at_boost@@IAEXAAV?$basic_string@_WU?$char_traits@_W_at_std@@V?$allocator@_W_at_2@@std@@@Z)
1>repository.lib(Archive.obj) : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::basic_xml_grammar<char>::init(class std::basic_istream<char,struct std::char_traits<char> > &)" (?init@?$basic_xml_grammar_at_D@archive_at_boost@@QAEXAAV?$basic_istream_at_DU?$char_traits_at_D@std@@@std@@@Z) referenced in function "protected: void __thiscall boost::archive::xml_iarchive_impl<class rs::InputArchive>::init(void)" (?init@?$xml_iarchive_impl_at_VInputArchive@rs@@@archive_at_boost@@IAEXXZ)
1>C:\Documents and Settings\Administrator\My Documents\Development\development\build\bin\Debug\repository_test_repository.exe : fatal error LNK1120: 6 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Development\development\build\components\libs\repository\repository_test_repository.dir\Debug\BuildLog.htm"
1>repository_test_repository - 13 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========
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