Rapidjson cannot copy `rapidjson::Document`

余生长醉 提交于 2019-12-11 09:55:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!