Boost logo

Boost Users :

Subject: [Boost-users] Serialization linker error: wstring and libcpmt.lib
From: Justin (jjplawnewera_at_[hidden])
Date: 2010-12-19 21:35:10


Hi guys, I have just started to use boost::serialization to serialize a complex data structure in a VS2005 MFC project. I'm still very unfamiliar with boost but i need to get this done by then end of the day. I ran into a couple of linker errors during compilation: error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@QBEIXZ) already defined in msvcprt.lib(MSVCP80.dll) libcpmt.lib there are 24 others of the similar error. If i ignore libcpmt.lib in the linker options, it'll *solve* the errors but is this the correct method? error LNK2019: unresolved external symbol "public: void __thiscall boost::archive::text_iarchive_impl<class boost::archive::text_iarchive>::load(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &)" (?load@?$text_iarchive_impl_at_Vtext_iarchive_at_archive@boost@@@archive_at_boost@@QAEXAAV?$basic_string_at_GU?$char_traits_at_G@std@@V?$allocator_at_G@2@@std@@@Z) referenced in function "public: class boost::archive::text_iarchive & __thiscall boost::archive::detail::interface_iarchive<class boost::archive::text_iarchive>::operator>><class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > >(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &)" (??$?5V?$basic_string_at_GU?$char_traits_at_G@std@@V?$allocator_at_G@2@@std@@@?$interface_iarchive_at_Vtext_iarchive_at_archive@boost@@@detail_at_archive@boost@@QAEAAVtext_iarchive_at_23@AAV?$basic_string_at_GU?$char_traits_at_G@std@@V?$allocator_at_G@2@@std@@@Z) this error is cause by the use of std::wstring inside my data structure. if i change it to std::string then it'll compile fine. My data structure: std::vector<DrvCfgData> DrvData; struct DrvCfgData { std::wstring ServerName; DWORD IPAddr; int PollRate; std::list<RptData> Reporting; } struct RptData { std::wstring RptName; std::wstring RptId; std::wstring RptData; std::wstring RptOps; bool param1; int param1data; bool param2; std::string param2data; bool param3; int param3data; bool param4; int param4data; } I've included the following header files in my project: #include <boost/serialization/vector.hpp> #include <boost/serialization/list.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> Please advise. Thanks. justin



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