VC6.0中解决 error LNK2005 相关问题方法

今天在编译一个工程的时候,遇到以下的问题:

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
test.c
C:\Documents and Settings\Administrator\桌面\test\test.c(96) : warning C4013: 'memcpy' undefined; assuming extern returning int
Linking...
LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : warning LNK4006: __cinit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: _exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __cexit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __c_exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __exitflag already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __wenviron already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: ___initenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __environ already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: ___wargv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argc already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __winminor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __winmajor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
   Creating library Debug/test.lib and object Debug/test.exp
LINK : warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/test.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Creating browse info file...

test.dll - 23 error(s), 24 warning(s)

在网上搜了很多的资料,最后得出一般的解决方法:

这种情况下,通常都是由于重复编译运行时库所致。具体原因不明,但可以肯定的是,链接库重复链接了。

可以通过以下方法去掉重复的部分:

在Project中打开Project Setting设置对话框,选择Link选中Category旁边下拉框的Input项。

在Ignore Libraries下面填入需要屏蔽的lib,这里比如是LIBCMTD.lib

重新编译,连接,成功!

--------------------Configuration: test - Win32 Debug--------------------
Linking...
   Creating library Debug/test.lib and object Debug/test.exp

test.dll - 0 error(s), 0 warning(s)

一点点的错误,谨以记下来以备查用....

你可能感兴趣的:(error)