LNK2019: “Unresolved external symbol” with rapidjson

后端 未结 2 908
盖世英雄少女心
盖世英雄少女心 2021-01-21 21:47

I have a Visual C++ Project in which I added the rapidjson library, which is tested to be working properly. But when I add a rapidjson::Document type to the nested

相关标签:
2条回答
  • 2021-01-21 22:02

    Looking at the error it appears that the function returning the jsonObj is doing some kind of a copy or move construction as a part of returning the value and the underlying classes do not allow this probably by making those constructors private members.

    There are classes whose design requires that a copy or assignment is prohibited in order to prevent memory leaks or because the objects are singleton type objects and only one version of the object is allowed.

    Looking at this documentation on rapidjson there is a note in the section on Move semantics that may be pertinent. It looks like they are preventing a Copy in order to improve performance.

    0 讨论(0)
  • 2021-01-21 22:15

    jsonObj doesn't have copy constructor and it can't have any copy constructor since Document's copy constructor is disabled in rapidjson. Try to hold pointer to document instead, something like this :

    class jsonObj {
        string jsonStr;
        string message;
        Document* doc; //HERE IS THE PROBLEM
        bool validMsg;
    }
    

    Or pass document(jsonObj) from outside to:

    jsonObj query(string sSQL);
    

    For example:

    query(string sSQL, jsonObj & out_obj)
    
    0 讨论(0)
提交回复
热议问题