1

After trying to build this simple program:

#include <iostream>
#include <cstdlib>

using namespace std;

void main()
{
    int a = 6;

    cout << a << endl;
}

I get many "unresolved external symbol" errors:

LNK1120 12 unresolved external errors
Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol strcat_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPEAXPEBD@Z)    CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_error_.obj)  1   
Error   LNK2019 unresolved external symbol strcpy_s referenced in function "void __cdecl _RTC_StackFailure(void *,char const *)" (?_RTC_StackFailure@@YAXPEAXPEBD@Z)    CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_error_.obj)  1   
Error   LNK2019 unresolved external symbol wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)  CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   
Error   LNK2019 unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT   CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_init_.obj)   1   
Error   LNK2019 unresolved external symbol _CrtDbgReportW referenced in function _CRT_RTC_INITW CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_init_.obj)   1   
Error   LNK2019 unresolved external symbol _wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z)  CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   
Error   LNK2019 unresolved external symbol _wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned __int64)" (?GetPdbDllPathFromFilePath@@YAHPEB_WPEA_W_K@Z) CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   
Error   LNK2001 unresolved external symbol __C_specific_handler CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_error_.obj)  1   
Error   LNK2019 unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l   CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_error_.obj)  1   
Error   LNK2019 unresolved external symbol __vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)  CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   
Error   LNK2019 unresolved external symbol __vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)    CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   
Error   LNK2019 unresolved external symbol __vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPEAUHINSTANCE__@@XZ)  CPP C:Documents\VSCPP\CPP\CPP\MSVCRTD.lib(_pdblkup_.obj)    1   

What is causing this and how this can be fixed?

  • Please add "/VERBOSE:LIB" to linker options and post the output. Propably some of your LIB pathes are incorrect. – zett42 Sep 08 '17 at 13:46
  • I put that library in linker:Input:Additional Dependencies and got all LNK2001 errors and the LNK1120 error. Still 12 errors. –  Sep 08 '17 at 14:34

1 Answers1

0

I encountered errors much the same as you report here. I solved my issues by including these libraries for the Release config:

vcruntime.lib

And for the Debug config:

vcruntimed.lib
ucrtd.lib

It is unclear to me why the debug version, vcruntimed.lib, would require an additional library, but it does.

This question is related to LNK2019 unresolved external symbol _CrtDbgReport referenced in function _CRT_RTC_INIT SDL2

neuralmer
  • 573
  • 3
  • 11