问题
I need a function that constructs a rapidjson::Document
and returns. But when I write a function with this prototype:
rapidjson::Document progressToJson(const Progress& progress);
I get this error:
error LNK2019: unresolved external symbol "private: __thiscall rapidjson::GenericValue<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> >::GenericValue<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> >(class rapidjson::GenericValue<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> > const &)" (??0?$GenericValue@U?$UTF8@D@rapidjson@@V?$MemoryPoolAllocator@VCrtAllocator@rapidjson@@@2@@rapidjson@@AAE@ABV01@@Z) referenced in function "public: __thiscall rapidjson::GenericDocument<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> >::GenericDocument<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> >(class rapidjson::GenericDocument<struct rapidjson::UTF8<char>,class rapidjson::MemoryPoolAllocator<class rapidjson::CrtAllocator> > const &)" (??0?$GenericDocument@U?$UTF8@D@rapidjson@@V?$MemoryPoolAllocator@VCrtAllocator@rapidjson@@@2@@rapidjson@@QAE@ABV01@@Z)
Seems there is not copy constructor. How can I solve this problem? BTW when I compile this with Eclipse as an Android Native code, it compiles and works. I get this error with MVS 2012 on Windows.
回答1:
Pass an empty document as argument and try to parse into it with its memory allocator:
void progressToJson(const Progress & progress, rapidjson::Document & doc);
来源:https://stackoverflow.com/questions/26075268/rapidjson-cannot-copy-rapidjsondocument