MFC下面TRACE有时遇到问题用不了解决办法


问题场景:


我的工程里面引入了libpng.lib、libzlib.lib 两个现成的静态库以及一个zlib1.dll文件,编译就出现了问题:


先把Character Set设置为:Not Set

(Configuration Properties -> Genearl -> Project Defaults -> Character Set)


如果没有调用TRACE函数,在编译的过程中出现了警告:

LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library


如果调用了TRACE函数,进行编译输出如下错误:

1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(mbctype.obj) : error LNK2005: __setmbcp already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(_file.obj) : error LNK2005: ___iob_func already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in msvcrtd.lib(MSVCR100D.dll)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
1>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in msvcrtd.lib(MSVCR100D.dll)
1>msvcrtd.lib(MSVCR100D.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj)
1>LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>E:\dev\proj\cpp\mfc\PngTest\Debug\PngTest.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.92
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


解决办法:

Configuration Properties -> Linker -> Input -> Ignore Specific Defualt Libraries : LIBCMT.lib


网上的解决办法:


在自己代码连接其他lib或者dll时,msvcrt.lib和libcmt.lib冲突,只需要把使用./MD(多线程dll)重新编译下
lib或者dll文件,就可以了。


你可能感兴趣的:(mfc,VS2010,bug,trace)