
Hello. I'm trying to use the boost serialization library. I'm using Visual C++ 7.1 under Windows 2000. The Boost.Serialization library seems excellent, and its ease of use is great. However I'm having two problems with it: First Problem. Here's the code: cdx::shrec_script script(""); std::ofstream ofs("compiled_shrec.txt"); boost::archive::text_oarchive oa(ofs); oa << script; // close archive ofs.close(); I get an error from boost static_assert, static_assert.hpp (below). Line 437 of regexconv.hpp refers to the "oa << script;" statement. If I copy the script archive to a new const object: const cdx::shrec_script temp_script(script); And try to serialize the temp_script object, the error goes away, and everything (seems to) work okay. I don't really have a problem with copying it, although it is inconvenient, in order to get this to work. However, the real problem is when I try to de-serialize the class: cdx::shrec_script script(""); std::ifstream ifs("compiled_shrec.txt"); boost::archive::text_iarchive oa(ifs); ia << script; // close archive ifs.close(); I get the same error (below). This is the big problem, because obviously the object needs to be non-const to be altered with the new data. I tried doing the same trick as above to get it to work (copy to a const object), but I still get the STATIC_ASSERTION_FAILURE error. c:\Boost\include\boost-1_33\boost\archive\detail\oserializer.hpp(551) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' with [ x=false ] c:\Boost\include\boost-1_33\boost\archive\detail\oserializer.hpp(551) : see reference to class template instantiation 'boost::STATIC_ASSERTION_FAILURE<x>' being compiled with [ x=false ] c:\Boost\include\boost-1_33\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled with [ Archive=boost::archive::text_oarchive, T=cdx::shrec_script ] c:\Boost\include\boost-1_33\boost\archive\detail\interface_oarchive.hpp(76) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=cdx::shrec_script ] regexconv.hpp(437) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<cdx::shrec_script>(T &)' being compiled with [ Archive=boost::archive::text_oarchive, T=cdx::shrec_script ] Second Problem. I'm getting linker errors when trying to compile Boost.Serialization with multi threaded runtimes in VC71. Linker errors are pasted at the bottom of this message. Somebody had told me that boost-1.31 and up headers now provide the proper #pragma for linking with the correct static library automagically, but I tried adding the #pragma's myself anyway. I'm not sure exactly what library to link with (there are lots of libbost_serialization*.lib files), so I tried each one. Each produced different results with different linker errors ranging from multiply defined symbols to unresolved externals. One did compile, however: #pragma comment(lib, "libboost_serialization-vc71-s.lib") But the program crashes as soon as it is run with the error (an uncaught exception): This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Press any key to continue I'm assuming this may be related to the fact that the 's' in libboost_serialization-vc71-s.lib means that the lib is compiled for single threads, and this is a multi threaded program. But of course, I'm probably wrong. Any light anybody can shed on either of these issues would be greatly appreciated! Thanks! Brett aftli@optonline.net Compiling... boost_test.cpp Linking... Creating library Release/boost_test.lib and object Release/boost_test.exp boost_test.obj : error LNK2001: unresolved external symbol "private: static char const * const boost::serialization::detail::extended_type_info_typeid_0::type_info_key" (?type_info_key@extended_type_info_typeid_0@detail@serialization@boost@@0PBD B) boost_test.obj : error LNK2019: unresolved external symbol "protected: virtual __thiscall boost::archive::detail::basic_iarchive::~basic_iarchive(void)" (??1basic_iarchive@detail@archive@boost@@MAE@XZ) referenced in function "public: virtual __thiscall boost::archive::detail::common_iarchive<class boost::archive::text_iarchive>::~common_iarchive<class boost::archive::text_iarchive>(void)" (??1?$common_iarchive@Vtext_iarchive@archive@boost@@@detail@archive@boost@@U AE@XZ) boost_test.obj : error LNK2019: unresolved external symbol "protected: virtual __thiscall boost::archive::detail::basic_oarchive::~basic_oarchive(void)" (??1basic_oarchive@detail@archive@boost@@MAE@XZ) referenced in function "public: virtual __thiscall boost::archive::detail::common_oarchive<class boost::archive::text_oarchive>::~common_oarchive<class boost::archive::text_oarchive>(void)" (??1?$common_oarchive@Vtext_oarchive@archive@boost@@@detail@archive@boost@@U AE@XZ) boost_test.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::serialization::extended_type_info::self_register(void)" (?self_register@extended_type_info@serialization@boost@@IAEXXZ) referenced in function "private: __thiscall boost::serialization::extended_type_info_typeid<class gps_position const
::extended_type_info_typeid<class gps_position const >(void)" (??0?$extended_type_info_typeid@$$CBVgps_position@@@serialization@boost@@AAE @XZ)
boost_test.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::text_oarchive_impl<class boost::archive::text_oarchive>::save(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?save@?$text_oarchive_impl@Vtext_oarchive@archive@boost@@@archive@boost@@QA EXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static void __cdecl boost::archive::save_access::save_primitive<class boost::archive::text_oarchive,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class boost::archive::text_oarchive &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$save_primitive@Vtext_oarchive@archive@boost@@V?$basic_string@DU?$char_tr aits@D@std@@V?$allocator@D@2@@std@@@save_access@archive@boost@@SAXAAVtext_oa rchive@12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z ) boost_test.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::text_iarchive_impl<class boost::archive::text_iarchive>::load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?load@?$text_iarchive_impl@Vtext_iarchive@archive@boost@@@archive@boost@@QA EXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static void __cdecl boost::archive::load_access::load_primitive<class boost::archive::text_iarchive,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class boost::archive::text_iarchive &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??$load_primitive@Vtext_iarchive@archive@boost@@V?$basic_string@DU?$char_tr aits@D@std@@V?$allocator@D@2@@std@@@load_access@archive@boost@@SAXAAVtext_ia rchive@12@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z ) boost_test.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::detail::basic_oarchive::basic_oarchive(void)" (??0basic_oarchive@detail@archive@boost@@IAE@XZ) referenced in function "protected: __thiscall boost::archive::detail::common_oarchive<class boost::archive::text_oarchive>::common_oarchive<class boost::archive::text_oarchive>(void)" (??0?$common_oarchive@Vtext_oarchive@archive@boost@@@detail@archive@boost@@I AE@XZ) boost_test.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::detail::basic_iarchive::basic_iarchive(void)" (??0basic_iarchive@detail@archive@boost@@IAE@XZ) referenced in function "protected: __thiscall boost::archive::detail::common_iarchive<class boost::archive::text_iarchive>::common_iarchive<class boost::archive::text_iarchive>(void)" (??0?$common_iarchive@Vtext_iarchive@archive@boost@@@detail@archive@boost@@I AE@XZ) boost_test.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_text_oprimitive<class std::basic_ostream<char,struct std::char_traits<char> >
::~basic_text_oprimitive<class std::basic_ostream<char,struct std::char_traits<char> > >(void)" (??1?$basic_text_oprimitive@V?$basic_ostream@DU?$char_traits@D@std@@@std@@@a rchive@boost@@QAE@XZ) referenced in function "public: virtual __thiscall boost::archive::text_oarchive_impl<class boost::archive::text_oarchive>::~text_oarchive_impl<class boost::archive::text_oarchive>(void)" (??1?$text_oarchive_impl@Vtext_oarchive@archive@boost@@@archive@boost@@UAE@X Z)
boost_test.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_text_iprimitive<class std::basic_istream<char,struct std::char_traits<char> >
::~basic_text_iprimitive<class std::basic_istream<char,struct std::char_traits<char> > >(void)" (??1?$basic_text_iprimitive@V?$basic_istream@DU?$char_traits@D@std@@@std@@@a rchive@boost@@QAE@XZ) referenced in function "public: virtual __thiscall boost::archive::text_iarchive_impl<class boost::archive::text_iarchive>::~text_iarchive_impl<class boost::archive::text_iarchive>(void)" (??1?$text_iarchive_impl@Vtext_iarchive@archive@boost@@@archive@boost@@UAE@X Z)
boost_test.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_text_iarchive<class boost::archive::text_iarchive>::load_override(struct boost::archive::class_name_type &,int)" (?load_override@?$basic_text_iarchive@Vtext_iarchive@archive@boost@@@archive @boost@@IAEXAAUclass_name_type@23@H@Z) referenced in function "private: virtual void __thiscall boost::archive::detail::common_iarchive<class boost::archive::text_iarchive>::vload(struct boost::archive::class_name_type &)" (?vload@?$common_iarchive@Vtext_iarchive@archive@boost@@@detail@archive@boos t@@EAEXAAUclass_name_type@34@@Z) boost_test.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_iarchive::load_object(void *,class boost::archive::detail::basic_iserializer const &)" (?load_object@basic_iarchive@detail@archive@boost@@QAEXPAXABVbasic_iserializ er@234@@Z) referenced in function "public: static void __cdecl boost::archive::detail::load_non_pointer_type<class boost::archive::text_iarchive,class gps_position>::load::invoke(class boost::archive::text_iarchive &,class gps_position &)" (?invoke@load@?$load_non_pointer_type@Vtext_iarchive@archive@boost@@Vgps_pos ition@@@detail@archive@boost@@SAXAAVtext_iarchive@45@AAVgps_position@@@Z) boost_test.obj : error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::detail::basic_oarchive::save_object(void const *,class boost::archive::detail::basic_oserializer const &)" (?save_object@basic_oarchive@detail@archive@boost@@QAEXPBXABVbasic_oserializ er@234@@Z) referenced in function "public: static void __cdecl boost::archive::detail::save_non_pointer_type<class boost::archive::text_oarchive,class gps_position>::save::invokex(class boost::archive::text_oarchive &,class gps_position const &)" (?invokex@save@?$save_non_pointer_type@Vtext_oarchive@archive@boost@@Vgps_po sition@@@detail@archive@boost@@SAXAAVtext_oarchive@45@ABVgps_position@@@Z) boost_test.obj : error LNK2001: unresolved external symbol "struct boost::archive::version_type const boost::archive::ARCHIVE_VERSION" (?ARCHIVE_VERSION@archive@boost@@3Uversion_type@12@B) boost_test.obj : error LNK2001: unresolved external symbol "char const * const boost::archive::ARCHIVE_SIGNATURE" (?ARCHIVE_SIGNATURE@archive@boost@@3PBDB) boost_test.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_text_oprimitive<class std::basic_ostream<char,struct std::char_traits<char> >
::basic_text_oprimitive<class std::basic_ostream<char,struct std::char_traits<char> > >(class std::basic_ostream<char,struct std::char_traits<char> > &,bool)" (??0?$basic_text_oprimitive@V?$basic_ostream@DU?$char_traits@D@std@@@std@@@a rchive@boost@@QAE@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@_N@Z) referenced in function "protected: __thiscall boost::archive::text_oarchive_impl<class boost::archive::text_oarchive>::text_oarchive_impl<class boost::archive::text_oarchive>(class std::basic_ostream<char,struct std::char_traits<char> > &,unsigned int)" (??0?$text_oarchive_impl@Vtext_oarchive@archive@boost@@@archive@boost@@IAE@A AV?$basic_ostream@DU?$char_traits@D@std@@@std@@I@Z)
boost_test.obj : error LNK2019: unresolved external symbol "public: __thiscall boost::archive::basic_text_iprimitive<class std::basic_istream<char,struct std::char_traits<char> >
::basic_text_iprimitive<class std::basic_istream<char,struct std::char_traits<char> > >(class std::basic_istream<char,struct std::char_traits<char> > &,bool)" (??0?$basic_text_iprimitive@V?$basic_istream@DU?$char_traits@D@std@@@std@@@a rchive@boost@@QAE@AAV?$basic_istream@DU?$char_traits@D@std@@@std@@_N@Z) referenced in function "public: __thiscall boost::archive::text_iarchive_impl<class boost::archive::text_iarchive>::text_iarchive_impl<class boost::archive::text_iarchive>(class std::basic_istream<char,struct std::char_traits<char> > &,unsigned int)" (??0?$text_iarchive_impl@Vtext_iarchive@archive@boost@@@archive@boost@@QAE@A AV?$basic_istream@DU?$char_traits@D@std@@@std@@I@Z)
Release/boost_test.exe : fatal error LNK1120: 17 unresolved externals Build Time 0:01