Snažím sa serialize triedy s std::wstring
premenná, ale to, čo som stále sú viaceré undefined reference to ~
chyby.
Neviem, zdá sa, chýba všetky hlavičky alebo knižnice & z toho, čo som čítal od boost::serialization
dokumenty, std::wstring
zdá sa, že primitívne typ, ktorý nepotrebuje žiadne závažné.
Som súčasťou týchto hlavičiek:
#include <boost/archive/text_woarchive.hpp>
#include <boost/archive/text_wiarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <locale>
Triedy sa snažím serialize vyzerá takto:
class A
{
public:
A() = default;
void setWstr(const std::wstring &wstr)
{
wstr_ = wstr;
}
const std::wstring &getWstr()
{
return wstr_;
};
private:
std::wstring wstr_;
friend class boost::serialization::access;
template <typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar &boost::serialization::make_nvp("wstr", wstr_);
}
};
int main()
{
std::wstring sdn = L"src dept";
A test;
test.setWstr(sdn);
std::wstringstream ss;
boost::archive::text_woarchive oa(ss);
oa << test;
return 0;
}
Chyby som stále sú tieto:
in function `text_woarchive_impl':
undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<wchar_t, std::char_traits<wchar_t> > >::basic_text_oprimitive(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >&, bool)'
in function `text_woarchive_impl':
undefined reference to `boost::archive::basic_text_oarchive<boost::archive::text_woarchive>::init()'
`~text_woarchive_impl':
undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<wchar_t, std::char_traits<wchar_t> > >::~basic_text_oprimitive()'
Existuje spôsob, ako vyriešiť tento problém?
ETA) som prepojené nasledovné knižnice
-lboost_serialization -lpthread -lboost_system -lboost_program_options -lboost_chrono
wchar_t
...