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)
13651정성태6/19/2024333닷넷: 2266. C# - (Reflection 없이) DLL AssemblyFileVersion 구하는 방법파일 다운로드1
13650정성태6/18/2024312개발 환경 구성: 713. "WSL --debug-shell"로 살펴보는 WSL 2 VM의 리눅스 환경
13649정성태6/18/2024322오류 유형: 910. windbg - !py 확장 명령어 실행 시 "failed to find python interpreter" (2)
13648정성태6/17/2024347오류 유형: 909. C# - DynamicMethod 사용 시 System.TypeAccessException
13647정성태6/16/2024521개발 환경 구성: 712. Windows - WSL 2의 네트워크 통신 방법 - 세 번째 이야기 (같은 IP를 공유하는 WSL 2 인스턴스)
13646정성태6/14/2024522오류 유형: 908. Process Explorer - "Error configuring dump resources: The system cannot find the file specified."
13645정성태6/13/2024899개발 환경 구성: 711. Visual Studio로 개발 시 기본 등록하는 dev tag 이미지로 Docker Desktop k8s에서 실행하는 방법
13644정성태6/12/2024963닷넷: 2265. C# - System.Text.Json의 기본적인 (한글 등에서의) escape 처리
13643정성태6/12/20241026오류 유형: 907. MySqlConnector 사용 시 System.IO.FileLoadException 오류
13642정성태6/11/20241014스크립트: 65. 파이썬 - asgi 버전(2, 3)에 따라 달라지는 uvicorn 호스팅
13641정성태6/11/20241095Linux: 71. Ubuntu 20.04를 22.04로 업데이트
13640정성태6/10/20241093Phone: 21. C# MAUI - Android 환경에서의 파일 다운로드(DownloadManager)
13639정성태6/8/20241015오류 유형: 906. C# MAUI - Android Emulator에서 "Waiting For Debugger"로 무한 대기
13638정성태6/8/20241112오류 유형: 905. C# MAUI - 추가한 layout XML 파일이 Resource.Layout 멤버로 나오지 않는 문제
13637정성태6/6/20241163Phone: 20. C# MAUI - 유튜브 동영상을 MediaElement로 재생하는 방법
13636정성태5/30/20241205닷넷: 2264. C# - 형식 인자로 인터페이스를 갖는 제네릭 타입으로의 형변환파일 다운로드1
13635정성태5/29/2024985Phone: 19. C# MAUI - 안드로이드 "Share" 대상으로 등록하는 방법
13634정성태5/24/20241229Phone: 18. C# MAUI - 안드로이드 플랫폼에서의 Activity 제어
13633정성태5/22/20241182스크립트: 64. 파이썬 - ASGI를 만족하는 최소한의 구현 코드
13632정성태5/20/20241488Phone: 17. C# MAUI - Android 내에 Web 서비스 호스팅
13631정성태5/19/20241511Phone: 16. C# MAUI - /Download 등의 공용 디렉터리에 접근하는 방법
13630정성태5/19/20241879닷넷: 2263. C# - Thread가 Task보다 더 빠르다는 어떤 예제(?)
13629정성태5/18/20241668개발 환경 구성: 710. Android - adb.exe를 이용한 파일 전송
13628정성태5/17/20241652개발 환경 구성: 709. Windows - WHPX(Windows Hypervisor Platform)를 이용한 Android Emulator 가속
13627정성태5/17/20241634오류 유형: 904. 파이썬 - UnicodeEncodeError: 'ascii' codec can't encode character '...' in position ...: ordinal not in range(128)
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...