Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

Visual Studio - /NODEFAULTLIB 옵션 설정 후 수동으로 추가해야 할 library

간단하게 Visual C++ Console Application 프로젝트를 만들고, 소스코드를 다음과 같이 구성합니다.

class CTest
{
};

int main()
{
    CTest* ptr = new CTest();
}

이 상태에서 프로젝트 속성 창을 통해 "Yes (/NODEFAULTLIB)" 옵션을 주면,

nodefaultlib_1.png

이제 빌드 시 다음과 같은 오류가 발생합니다.

Error   LNK2019 unresolved external symbol "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) referenced in function main ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol strlen referenced in function "public: static unsigned __int64 __cdecl std::_Narrow_char_traits<char,int>::length(char const * const)" (?length@?$_Narrow_char_traits@DH@std@@SA_KQEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __cdecl std::ios_base::good(void)const " (__imp_?good@ios_base@std@@QEBA_NXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: int __cdecl std::ios_base::flags(void)const " (__imp_?flags@ios_base@std@@QEBAHXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::ios_base::width(void)const " (__imp_?width@ios_base@std@@QEBA_JXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z) ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::ios_base::width(__int64)" (__imp_?width@ios_base@std@@QEAA_J_J@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (__imp_?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: void __cdecl std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (__imp_?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z) ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (__imp_?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z)    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_streambuf<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (__imp_?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: char __cdecl std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: void __cdecl std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (__imp_?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ)   ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (__imp_?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z) ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol _RTC_CheckStackVars referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol _RTC_InitBase    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol _RTC_Shutdown    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol __CxxFrameHandler4   ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol __GSHandlerCheck_EH4 ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol __security_check_cookie referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A) referenced in function main ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2019 unresolved external symbol __security_cookie referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol mainCRTStartup   ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\LINK    1   
Error   LNK1120 24 unresolved externals ConsoleApplication1 C:\temp\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe   1   

오류를 보면, 가장 기본적인 new 연산자조차 없는 걸로 나옵니다.

LNK2019 unresolved external symbol "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) referenced in function main 

예전에 이에 대해 정리한 적이 있는데요,

MASM + CRT 함수를 사용하는 경우 발생하는 컴파일 오류 정리
; https://www.sysnet.pe.kr/2/0/13183

따라서 위와 같은 소스코드에서는 다음의 3개 library를 "Additional Dependencies"추가하면,

nodefaultlib_2.png

  • vcruntime.lib
  • ucrt.lib
  • libcmt.lib

정상적으로 빌드가 됩니다.




자, 그럼 소스코드에 stl을 사용해 볼까요? ^^

#include <iostream>

class CTest
{
};

int main()
{
    std::cout << "Hello World!\n";

    CTest* ptr = new CTest();
}

이제는 또다시 링커 에러가 발생하는데요,

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: bool __cdecl std::ios_base::good(void)const " (__imp_?good@ios_base@std@@QEBA_NXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: int __cdecl std::ios_base::flags(void)const " (__imp_?flags@ios_base@std@@QEBAHXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::ios_base::width(void)const " (__imp_?width@ios_base@std@@QEBA_JXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z) ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::ios_base::width(__int64)" (__imp_?width@ios_base@std@@QEAA_J_J@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (__imp_?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (__imp_?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: void __cdecl std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (__imp_?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z) ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (__imp_?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z)    ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_streambuf<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (__imp_?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)    ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: char __cdecl std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (__imp_?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z)  ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: void __cdecl std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (__imp_?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ)   ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (__imp_?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::sentry(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??0sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@AEAV12@@Z) ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK2019 unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A) referenced in function main ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj    1   
Error   LNK1120 14 unresolved externals ConsoleApplication1 E:\cloud_drive\Dropbox\articles\waveDest_compile\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe  1   

이에 대해서는 다음의 문서에 따라,

C runtime (CRT) and C++ standard library (STL) .lib files
; https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170#c-standard-library-stl-lib-files

"C++ standard library (STL) .lib files"를 위해 (문서에 나오는 것 중에서, 여기서는) msvcprt.lib와 링크하도록 설정을 추가합니다. 따라서, 대부분의 Visual C++ 프로젝트라면 다음의 4개 lib를 추가하면 됩니다.

  • vcruntime.lib
  • ucrt.lib
  • libcmt.lib
  • msvcprt.lib

위의 목록은 Release 빌드용이므로 디버깅을 위해서 'd' 글자가 붙은 버전을 사용할 수 있습니다.

  • vcruntimed.lib
  • ucrtd.lib
  • libcpmtd.lib
  • msvcprtd.lib

참고로 필요한 lib 파일명은 Visual Studio의 버전에 따라 달라질 수 있으므로 문서 링크에 있는 "view=msvc-170" 값에 따라 적절하게 찾아야 합니다.




libcmt.lib 없이 vcruntime.lib, ucrt.lib만 포함시키면 이렇게 링커 오류가 발생합니다.

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) referenced in function main ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol _RTC_InitBase    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol _RTC_Shutdown    ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj 1   
Error   LNK2001 unresolved external symbol mainCRTStartup   ConsoleApplication1 C:\temp\ConsoleApplication1\ConsoleApplication1\LINK    1   
Error   LNK1120 4 unresolved externals  ConsoleApplication1 C:\temp\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe   1   

또한, "$(CoreLibraryDependencies)"로 추가되는 라이브러리들은 다음과 같습니다.

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 4/6/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  [7]  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13419정성태9/25/20232470스크립트: 56. 파이썬 - RuntimeError: dictionary changed size during iteration
13418정성태9/25/20233020닷넷: 2146. C# - ConcurrentDictionary 자료 구조의 동기화 방식
13417정성태9/19/20232744닷넷: 2145. C# - 제네릭의 형식 매개변수에 속한 (매개변수를 가진) 생성자를 호출하는 방법
13416정성태9/19/20232536오류 유형: 877. redis-py - MISCONF Redis is configured to save RDB snapshots, ...
13415정성태9/18/20232949닷넷: 2144. C# 12 - 컬렉션 식(Collection Expressions)
13414정성태9/16/20232772디버깅 기술: 193. Windbg - ThreadStatic 필드 값을 조사하는 방법
13413정성태9/14/20232968닷넷: 2143. C# - 시스템 Time Zone 변경 시 이벤트 알림을 받는 방법
13412정성태9/14/20236179닷넷: 2142. C# 12 - 인라인 배열(Inline Arrays) [1]
13411정성태9/12/20232709Windows: 252. 권한 상승 전/후 따로 관리되는 공유 네트워크 드라이브 정보
13410정성태9/11/20234173닷넷: 2141. C# 12 - Interceptor (컴파일 시에 메서드 호출 재작성) [1]
13409정성태9/8/20233048닷넷: 2140. C# - Win32 API를 이용한 모니터 전원 끄기
13408정성태9/5/20232993Windows: 251. 임의로 만든 EXE 파일을 포함한 ZIP 파일의 압축을 해제할 때 Windows Defender에 의해 삭제되는 경우
13407정성태9/4/20232833닷넷: 2139. C# - ParallelEnumerable을 이용한 IEnumerable에 대한 병렬 처리
13406정성태9/4/20232793VS.NET IDE: 186. Visual Studio Community 버전의 라이선스
13405정성태9/3/20233172닷넷: 2138. C# - async 메서드 호출 원칙
13404정성태8/29/20232646오류 유형: 876. Windows - 키보드의 등호(=, Equals sign) 키가 눌리지 않는 경우
13403정성태8/21/20232570오류 유형: 875. The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
13402정성태8/20/20232639닷넷: 2137. ILSpy의 nuget 라이브러리 버전 - ICSharpCode.Decompiler
13401정성태8/19/20232893닷넷: 2136. .NET 5+ 환경에서 P/Invoke의 성능을 높이기 위한 SuppressGCTransition 특성 [1]
13400정성태8/10/20232743오류 유형: 874. 파이썬 - pymssql을 윈도우 환경에서 설치 불가
13399정성태8/9/20232845닷넷: 2135. C# - 지역 변수로 이해하는 메서드 매개변수의 값/참조 전달
13398정성태8/3/20233315스크립트: 55. 파이썬 - pyodbc를 이용한 SQL Server 연결 사용법
13397정성태7/23/20233042닷넷: 2134. C# - 문자열 연결 시 string.Create를 이용한 GC 할당 최소화
13396정성태7/22/20232780스크립트: 54. 파이썬 pystack 소개 - 메모리 덤프로부터 콜 스택 열거
13395정성태7/20/20232740개발 환경 구성: 685. 로컬에서 개발 중인 ASP.NET Core/5+ 웹 사이트에 대해 localhost 이외의 호스트 이름으로 접근하는 방법
13394정성태7/16/20232669오류 유형: 873. Oracle.ManagedDataAccess.Client - 쿼리 수행 시 System.InvalidOperationException
1  2  3  4  5  6  [7]  8  9  10  11  12  13  14  15  ...