I have a Visual C ++ project in which I added the rapidjson library, which is checked for proper operation. But when I add the type rapidjson::Document to the nested class, it throws an LNK2019 error when trying to compile. The project is a dynamic library for creating DLLs.
These are the definitions in my main.h :
class coreBD { string conn; string proxy; int type; Document test; enum dataBases { Sqlite, SqlServer, None }; string queryBD(string sSQL); string queryHTTP(string sSQL); string httpRequest(string url, string proxy); static string getNow(string format); static string urlEncode(string url); static bool startsWith(string source, string with); public: enum access { dbConn, HTTPProtocol };
This is mistake:
error LNK1120: 1 unresolved external
LNK2019 error: unresolved external symbol "private: __thiscall rapidjson :: GenericValue, class rapidjson :: MemoryPoolAllocator> :: GenericValue, class rapidjson :: MemoryPoolAllocator> (class rapidjson :: GenericValue, class rapidjson :: MemoryPoolAllocator> const &)" (? 0? $ GenericValue @U? $ UTF8 @D @rapidjson @@ V? $ MemoryPoolAllocator @VCrtAllocator @rapidjson @@@ 2 @@ rapidjson @@ AAE @ ABV01 @@ Z) link to the function "public: __thiscall rapidjson :: GenericDocument , class rapidjson :: MemoryPoolAllocator> :: class rapidjson :: MemoryPoolAllocator> (class rapidjson :: GenericDocument, class rapidjson :: MemoryPoolAllocator> const &) "(? 0? $ GenericDocument @U? $ UTF8 @D @rapidjson @ @V? $ MemoryPoolAllocator @VCrtAllocator @rapidjson @@@ 2 @@ rapidjson @@ QAE @ ABV01 @@ Z)
The error disappears when I comment on the line commented HERE, PROBLEM in the code. As you can see, using the test variable in the coreBD class coreBD not cause errors. The mere existence of a variable of type rapidjson::Document in a nested class causes an error; it doesnβt matter if I use it or not.
What could be the problem?
EDIT
New information collected.
The problem occurs when I use a nested class inside the parent, but only in the return method. In other words: I can create everything with type rapidjson::Document as a member variable, I can create a method in the coreBD class with type jsonObj , I can create an instance of jsonObj inside these methods , but I cannot return a value of type jsonObj if class jsonObj has a declared member variable rapidjson::Document .
For example, this new created method:
jsonObj coreBD::testOBJ() { string json = "{error:null, message:None, errorMessage:MoreNone}"; jsonObj b(json); return b;
EDIT
A new issue that continues to be addressed is: Run a copy of the Document rapidjson object