LNK2001 QByteArray::shared_null

다음과 같은 에러가 발생하는 경우 사용하려는 QT 모델(DLL, Static) 과 compiler 설정이 다른 경우이다

 

다음 내용을 확인한다.

  1. QT 는 DLL 을 사용할 경우 dll 버전은 QtCore4.lib 같이 뒤에 QT의 버전숫자가 붙는다.(static version은 QtCore.lib 처럼 숫자가 없음)
  2. C++ -> Code generation ->  Use runtime library 가 /MD (Multithreaded DLL) 인지 확인
     
  3. PreProcessor 에 QT_DLL  이 추가되었는지 확인(추가로 QT_THREAD_SUPPORT,QT_CORE_LIB macro도 추가)
CKErrorManager.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
MainClass.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
CKEntry.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
EMRAuthClient1.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
CKPkiWrapper.obj : error LNK2001: unresolved external symbol "public: static struct QListData::Data QListData::shared_null" (?shared_null@QListData@@2UData@1@A)
MainClass.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
CKEntry.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
MainClass.obj : error LNK2001: unresolved external symbol "public: static struct QVectorData QVectorData::shared_null" (?shared_null@QVectorData@@2U1@A)
CKEntry.obj : error LNK2001: unresolved external symbol "public: static struct QVectorData QVectorData::shared_null" (?shared_null@QVectorData@@2U1@A)
CKEntry.obj : error LNK2001: unresolved external symbol "private: static class QTextCodec * QString::codecForCStrings" (?codecForCStrings@QString@@0PAVQTextCodec@@A)
Debug/EMRAuthClientSVd.dll : fatal error LNK1120: 5 unresolved externals