LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrt.lib(MSVCRT.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrt.lib(cinitexe.obj)
LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrt.lib(MSVCRT.dll)
LINK : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/数据库端.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
涉及到多线程编程。若使用到动态库时,没有问题。用静态库,由于lib冲突,会出现编译错误。
1.使用静态库链接
2.设置-》c/c++->分类(code generation)->use run time library(选择MD)
3.在设置-》c/c++->分类(常规)-》预处理定义里加入 ,_AFXDLL
4. 属性,链接器,输入,忽略指定库 libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib
Debug模式下编译出现如下错误:
LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in libcmtd.lib(invarg.obj)
主要原因是链接了两个库LIBCMT and LIBCMTD,以至于出现already defined。
解决办法:
1.确保当前工程的Runtime Library和引用lib的Runtime Library相同便可以解决问题
比如:lib库的Runtime Library是MD,当前工程也得设置为MD。
2.In Debug mode,在Debug命令行中加上/FORCE:MULTIPLE