Visual Studio - /NODEFAULTLIB 옵션 설정 후 수동으로 추가해야 할 library
간단하게 Visual C++ Console Application 프로젝트를 만들고, 소스코드를 다음과 같이 구성합니다.
class CTest
{
};
int main()
{
CTest* ptr = new CTest();
}
이 상태에서 프로젝트 속성 창을 통해 "Yes (/NODEFAULTLIB)" 옵션을 주면,
이제 빌드 시 다음과 같은 오류가 발생합니다.
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"추가하면,
- 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
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]