用到一个静态库的接口:
#include "signcompress/signcompress.h"
#pragma comment(lib, "../commoncodes/A9L/signcompress/libsigncompress.lib")
结果报如下link错误:
Linking... libc.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __close already defined in libc.lib(close.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __write already defined in libc.lib(write.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __open already defined in libc.lib(open.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __read already defined in libc.lib(read.obj)
libc.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
libc.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
libc.lib(crt0init.obj) : warning LNK4006: ___xi_z already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
libc.lib(crt0init.obj) : warning LNK4006: ___xi_a already defined in MSVCRT.lib(cinitexe.obj); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __close already defined in libc.lib(close.obj); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __write already defined in libc.lib(write.obj); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __open already defined in libc.lib(open.obj); second definition ignored
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __read already defined in libc.lib(read.obj); second definition ignored
Creating library Release/LandiTmsV5_0_0.lib and object Release/LandiTmsV5_0_0.exp
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
MSVCRT.lib(cinitexe.obj) : warning LNK4098: defaultlib "libc.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
libc.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/LandiTmsV5_0_0.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
LandiTmsV5_0_0.dll - 10 error(s), 10 warning(s)
加上如下代码后问题解决:
#pragma comment(linker, "/NODEFAULTLIB:libc.lib")