intel编译器:libc.lib和msvcrt.lib冲突?如何解决 2010-9-28 18:13

来源:互联网 发布:sql count group by 编辑:程序博客网 时间:2024/05/22 19:38

现在开发directshow有点不合时宜了,快淘汰了嘛。我在visual studio 2008下开发filter的时候,参照了vc6的一些设置,结果就遇到了很多冲突问题。比如现在这个就很典型:libcmt.lib和msvcrt.lib。

warning LNK4098: defaultlib ‘LIBCMT’ conflicts with use of other libs; use /NODEFAULTLIB:library

这两个玩意儿在编译的时候是warning。一般我不大管warning,能编译成功就好了嘛。这次栽了。在自己的电脑上测试还行,如果上别人的没有visual studio 2008或2005的电脑上,就会报这样的错误:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

应该说是找不到某些dll(听说就是MSVCR80.DLL,不是谁都有的)吧。我在msdn上找到些解释:

Important The run-time libraries now contain directives to prevent mixing different types. You’ll receive this warning if you try touse different types or debug and non-debug versionsof the run-timelibrary in the same program. For example, if you compiled one file touse one kindof run-timelibrary and another file touse another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning. You should compile all source files touse the same run-timelibrary. See theUse Run-TimeLibrary (MD, /ML, /MT, /LD) compiler options for more information.

You can use the linker’s/VERBOSE:LIB switch to determine which libraries the linker is searching. If you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries,use the /VERBOSE:LIB option to find out which libraries the linker is searching. The linker should print LIBC.LIB and not LIBCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libraries searched. You can tell the linker to ignore the the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tabof the Settings dialog box in Developer’s Studio or by using the /NODEFAULTLIB:library optionwith LINK for eachlibrary you want to ignore. See theIgnore Libraries (/NODEFAULTLIB) linker option for more information.

The table below shows which libraries should be ignored depending on which run-timelibrary you want touse.

To use this run-time libraryIgnore these librariesSingle-threaded (libc.lib)libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.libMultithreaded (libcmt.lib)libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.libMultithreaded using DLL (msvcrt.lib)libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.libDebug Single-threaded (libcd.lib)libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.libDebug Multithreaded (libcmtd.lib)libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, msvcrtd.libDebug Multithreaded using DLL (msvcrtd.lib)libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib

就是说在设置Use Real-time Library的时候要选/Multi-threaded (/MT),这样就不会用到msvcrt.lib。然后根据那张表:要在Ignore Specific Library里面加上它们(如果是参照vc6来设置lib的话,有些教程上讲要加上msvcrtd.lib,其实并不需要)。msvcrt.lib是冲突源头,为什么?我不清楚,呵呵,推荐一篇文章:http://www.cnblogs.com/jedimaster/archive/2007/03/02/662065.html

原创粉丝点击