尝试构建这个简单的程序后:
#include <iostream>
#include <cstdlib>
using namespace std;
void main()
{
int a = 6;
cout << a << endl;
}
我得到很多&#34;未解决的外部符号&#34;错误:
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
造成这种情况的原因以及如何解决这个问题?
答案 0 :(得分:-3)
Visual studio链接到iostream。您的视觉工作室有一些问题。 但我现在可能正在修理它。
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include
iostream
(如果你没有,请阅读下面的10页。)iostream
// iostream standard header
#pragma once
#ifndef _IOSTREAM_
#define _IOSTREAM_
#ifndef RC_INVOKED
#include <istream>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma push_macro("new")
#undef new
_STD_BEGIN
#ifdef _M_CEE_PURE
__PURE_APPDOMAIN_GLOBAL extern istream cin, *_Ptr_cin;
__PURE_APPDOMAIN_GLOBAL extern ostream cout, *_Ptr_cout;
__PURE_APPDOMAIN_GLOBAL extern ostream cerr, *_Ptr_cerr;
__PURE_APPDOMAIN_GLOBAL extern ostream clog, *_Ptr_clog;
__PURE_APPDOMAIN_GLOBAL extern wistream wcin, *_Ptr_wcin;
__PURE_APPDOMAIN_GLOBAL extern wostream wcout, *_Ptr_wcout;
__PURE_APPDOMAIN_GLOBAL extern wostream wcerr, *_Ptr_wcerr;
__PURE_APPDOMAIN_GLOBAL extern wostream wclog, *_Ptr_wclog;
#else /* _M_CEE_PURE */
// OBJECTS
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT istream cin, *_Ptr_cin;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cout, *_Ptr_cout;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream cerr, *_Ptr_cerr;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT ostream clog, *_Ptr_clog;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wistream wcin, *_Ptr_wcin;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcout, *_Ptr_wcout;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wcerr, *_Ptr_wcerr;
__PURE_APPDOMAIN_GLOBAL extern _CRTDATA2_IMPORT wostream wclog, *_Ptr_wclog;
// CLASS _Winit
class _CRTIMP2_PURE_IMPORT _Winit {
public:
__thiscall _Winit();
__thiscall ~_Winit() _NOEXCEPT;
private:
__PURE_APPDOMAIN_GLOBAL static int _Init_cnt;
};
#endif /* _M_CEE_PURE */
_STD_END
#pragma pop_macro("new")
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _IOSTREAM_ */
/*
* Copyright (c) by P.J. Plauger. All rights reserved.
* Consult your license regarding permissions and restrictions.
V6.50:0009 */
如果你不喜欢iostream:
我希望我帮助过你。