如何解决LNK2001 / 2005问题?

时间:2016-03-23 10:07:35

标签: c++ visual-studio visual-c++ linker

我在Visual C ++ 2000 Express中遇到了很多LNK2001 / 2005问题:

1>------ Build started: Project: lice, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(518,5): error MSB8008: Specified platform toolset (v140) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
2>------ Build started: Project: IPlug, Configuration: Debug Win32 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(518,5): error MSB8008: Specified platform toolset (v140) is not installed or invalid. Please make sure that a supported PlatformToolset value is selected.
3>------ Build started: Project: MyFirstPlugin-app, Configuration: Debug Win32 ------
3>asio.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
3>LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf already defined in IPlug.lib(IPlugBase.obj)
3>LIBCMTD.lib(vsprintf.obj) : error LNK2005: __vsprintf_l already defined in IPlug.lib(IPlugBase.obj)
3>IPlug.lib(IPopupMenu.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>lice.lib(lice_png.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>lice.lib(lice.obj) : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z) referenced in function "public: static void __cdecl _LICE_Template_Blit2<class _LICE_CombinePixelsMulSourceAlphaClamp>::scaleBlit(unsigned char *,unsigned char *,int,int,int,int,int,int,int,int,int,int,int,int)" (?scaleBlit@?$_LICE_Template_Blit2@V_LICE_CombinePixelsMulSourceAlphaClamp@@@@SAXPAE0HHHHHHHHHHHH@Z)
3>lice.lib(lice_textnew.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>IPlug.lib(IPlugBase.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>IPlug.lib(IGraphicsWin.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>IPlug.lib(IGraphics.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>IPlug.lib(IControl.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned int)" (??3@YAXPAXI@Z)
3>IPlug.lib(IPlugBase.obj) : error LNK2019: unresolved external symbol ___stdio_common_vfprintf referenced in function __vfprintf_l
3>lice.lib(pngerror.obj) : error LNK2001: unresolved external symbol ___stdio_common_vfprintf
3>IPlug.lib(IParam.obj) : error LNK2001: unresolved external symbol ___stdio_common_vsprintf
3>IPlug.lib(IPlugBase.obj) : error LNK2019: unresolved external symbol ___stdio_common_vsprintf referenced in function __vsnprintf_l
3>IPlug.lib(Log.obj) : error LNK2001: unresolved external symbol ___stdio_common_vsprintf
3>IPlug.lib(IPlugStructs.obj) : error LNK2001: unresolved external symbol ___stdio_common_vsprintf
3>IPlug.lib(IGraphicsWin.obj) : error LNK2001: unresolved external symbol ___stdio_common_vsprintf
3>IPlug.lib(IPlugBase.obj) : error LNK2019: unresolved external symbol ___stdio_common_vsscanf referenced in function __vsscanf_l
3>IPlug.lib(Log.obj) : error LNK2019: unresolved external symbol __Init_thread_header referenced in function "char const * __cdecl AppendTimestamp(char const *,char const *,char const *)" (?AppendTimestamp@@YAPBDPBD00@Z)
3>lice.lib(lice_textnew.obj) : error LNK2001: unresolved external symbol __Init_thread_header
3>IPlug.lib(Log.obj) : error LNK2019: unresolved external symbol __Init_thread_footer referenced in function "char const * __cdecl AppendTimestamp(char const *,char const *,char const *)" (?AppendTimestamp@@YAPBDPBD00@Z)
3>lice.lib(lice_textnew.obj) : error LNK2001: unresolved external symbol __Init_thread_footer
3>IPlug.lib(Log.obj) : error LNK2001: unresolved external symbol __Init_thread_epoch
3>lice.lib(lice_textnew.obj) : error LNK2001: unresolved external symbol __Init_thread_epoch
3>IPlug.lib(IGraphicsWin.obj) : error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function "void __cdecl GetModulePath(struct HINSTANCE__ *,class WDL_String *)" (?GetModulePath@@YAXPAUHINSTANCE__@@PAVWDL_String@@@Z)
3>lice.lib(pngerror.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
3>lice.lib(pngrutil.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
3>lice.lib(inftrees.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
3>lice.lib(pngerror.obj) : error LNK2019: unresolved external symbol ___acrt_iob_func referenced in function _png_default_error
3>lice.lib(pngget.obj) : error LNK2019: unresolved external symbol __dtoui3 referenced in function _png_get_pHYs_dpi
3>build-win\app\Win32\bin\MyFirstPlugin.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========

我不知道他们来自哪里。我正在按照this教程设置我的环境来制作音频插件。正如教程中所建议的那样,我设置了"Properties → Linker (General) → Enable Incremental Linking → “No (/INCREMENTAL:NO)”"但没有任何成功。我也设置了SP1。

有什么帮助吗?我也试过Visual Studio 2015,但我也遇到了其他问题。所以它最好先适应教程...但我无法继续解决这些问题。

1 个答案:

答案 0 :(得分:2)

从它的外观来看,这里有三种不同类型的链接器错误 - 希望只有一个修复。

error LNK2005: _sprintf already defined in IPlug.lib(IPlugBase.obj)
此错误表明相关库(IPlug.lib)已compiled using a different runtime-library链接(静态或动态,调试或发布)This link describes the compiler-settings for these。您需要确定正确的设置,以便您的项目与所链接的库相匹配

IPlug.lib(IPlugBase.obj) : error LNK2019: unresolved external symbol ___stdio_common_vfprintf referenced in function __vfprintf_l

由于之前的错误,出现了(虽然可能不是),但运行时库尚未链接,因此它的组件(如fprintf)无法链接。 这应该通过修复上一期

来解决
lice.lib(inftrees.obj) : error LNK2001: unresolved external symbol ___report_rangecheckfailure
lice.lib(pngerror.obj) : error LNK2019: unresolved external symbol ___acrt_iob_func referenced in function _png_default_error

这两个问题似乎是实际未解决的符号,这些希望通过修复第一个问题来解决 - 如果没有,您将错过项目所需的库。研究文档直到找到它。

更新

经过一番努力后,发现OP已经错过了在他所关注的教程中使用git checkout的步骤,因为他链接的库与他的Visual-Studio版本不兼容