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@DU?$char_traits@D@std@@V?$allocator@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@Vtext_iarchive@archive@boost@@@archive@boost@@QAEXAAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@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@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@?$interface_iarchive@Vtext_iarchive@archive@boost@@@detail@archive@boost@@QAEAAVtext_iarchive@23@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@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