제대로 작동하는 것으로 테스트 된 rapidjson 라이브러리를 추가 한 Visual C++ 프로젝트가 있습니다. 하지만 rapidjson::Document
유형을 중첩 클래스에 추가하면 컴파일 할 때 LNK2019
오류가 발생합니다. 프로젝트는 DLL을 만드는 동적 라이브러리입니다. LNK2019 : rapidjson과 함께 "확인되지 않은 외부 기호"
이
내 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
};
//Nested class
class jsonObj {
string jsonStr;
string message;
Document doc; //HERE IS THE PROBLEM
bool validMsg;
public:
enum response {
FullResponse,
SQLResponse
};
jsonObj(string json);
string getJsonStr(response rType);
string getErrorMsg();
bool isValidResponse();
};
coreBD(string connStr, access connType);
jsonObj query(string sSQL);
void setProxy(string proxy);
};
이 오류입니다 : 내가 선이 여기 주석으로 언급 할 때
이error LNK1120: 1 unresolved externals
error LNK2019: unresolved external symbol "private: __thiscall rapidjson::GenericValue,class rapidjson::MemoryPoolAllocator >::GenericValue,class rapidjson::MemoryPoolAllocator >(class rapidjson::GenericValue,class rapidjson::MemoryPoolAllocator > const &)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@@Z) referenced in function "public: __thiscall rapidjson::GenericDocument,class rapidjson::MemoryPoolAllocator >::GenericDocument,class rapidjson::MemoryPoolAllocator >(class rapidjson::GenericDocument,class rapidjson::MemoryPoolAllocator > const &)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@@Z)
오류가 사라집니다 문제는 코드에서 보시다시피, test
변수를 coreBD
클래스에 사용하면 오류가 발생하지 않습니다. 중첩 된 클래스에 rapidjson::Document
유형의 변수가 존재하면 오류가 표시됩니다. 내가 사용하는지 여부는 중요하지 않습니다.
무엇이 문제 일 수 있습니까?
편집 :
새로운 정보를 수집.
부모 개체 내부에서 중첩 된 클래스를 사용할 때 문제가 발생하지만 메서드의 return
에서만 발생합니다. 즉 : 나는, 내가 형 jsonObj
와 coreBD
클래스의 방법을 만들 수있는 멤버 변수로 rapidjson::Document
유형으로 모든 것을 만들 수 있습니다, 그 방법 내부 jsonObj
, 을 인스턴스화 할 수 있지만 클래스 경우 유형 jsonObj
의 값을 반환 할 수 없습니다 jsonObj
에는 rapidjson::Document
멤버 변수가 선언되어 있습니다. 예를 들어
이 새로운 생성 방법 :
jsonObj coreBD::testOBJ()
{
string json = "{error:null, message:None, errorMessage:MoreNone}";
jsonObj b(json);
return b; //It fails here if I return a nested class with a rapidjson::Document in it. Returning NULL works
}
편집 :
새로운 문제를 계속 해결이 : Perform a copy of Document object of rapidjson
rapidjason의 라이브러리 파일을 프로젝트 속성의 참조로 사용하십시오. –
@Trinity rapidjson은 단지 헤더이며, # include와 함께 프로젝트에 포함되어 있습니다. 당신이 읽을 수있는 한, 라이브러리는 프로젝트의 다른 모든 부분에서 제대로 작동하고 있습니다. – SysDragon
언제든지이 솔루션이 별도의 솔루션입니까? 응용 프로그램의 다른 작업 부분이 프로젝트의 다른 솔루션에 배치된다는 것을 의미합니다. – XAMlMAX