C_and_CPP 版 (精华区)

发信人: hua (pupa), 信区: C_and_CPP
标  题: Linker Tools Warning LNK4098:defaultlib "library" conflicts
发信站: 哈工大紫丁香 (Thu Dec 23 11:57:51 2004), 转信

Linker Tools Warning LNK4098

defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB
:library

You are trying to link with incompatible libraries.

Important   The run-time libraries now contain directives to prevent mix
ing different types. You’ll receive this warning if you try to use diff
erent types or debug and non-debug versions of the run-time library in t
he same program. For example, if you compiled one file to use one kind o
f run-time library and another file to use another kind (for example, si
ngle-threaded versus multithreaded) and tried to link them, you’ll get 
this warning. You should compile all source files to use the same run-ti
me library. See the Use Run-Time Library (MD, /ML, /MT, /LD) compiler op
tions for more information. 

You can use the linker’s /VERBOSE:LIB switch to determine which librari
es 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 librar
ies the linker is searching. The linker should print LIBC.LIB and not LI
BCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libr
aries 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 tab of the Settings dialog box in Developer’s Stu
dio or by using the /NODEFAULTLIB:library option with LINK for each libr
ary you want to ignore. See the Ignore Libraries (/NODEFAULTLIB) linker 
option for more information.

The table below shows which libraries should be ignored depending on whi
ch run-time library you want to use.

To use this run-time library Ignore these libraries 

Single-threaded (libc.lib) libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.li
b, msvcrtd.lib 

Multithreaded (libcmt.lib) libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib,
 msvcrtd.lib 

Multithreaded using DLL (msvcrt.lib) libc.lib, libcmt.lib, libcd.lib, li
bcmtd.lib, msvcrtd.lib 

Debug Single-threaded (libcd.lib) libc.lib, libcmt.lib, msvcrt.lib, libc
mtd.lib, msvcrtd.lib 

Debug Multithreaded (libcmtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libc
d.lib, msvcrtd.lib 

Debug Multithreaded using DLL (msvcrtd.lib) libc.lib, libcmt.lib, msvcrt
.lib, libcd.lib, libcmtd.lib 

For example, if you received this warning and you want to create an exec
utable file that uses the non-debug, single-threaded version of the run-
time libraries, you could use the following options with the linker:

/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.li
b /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB写程序看到 warning,感觉不爽。 
这个警告在 link option 中 加入 对应的  /NODEFAULTLIB:xxx.lib   就ok了


--
无名天地之始;有名万物之母。故常无,欲以观其妙;常有,欲以观其徼。此两者,
同出而异名,同谓之玄。玄之又玄,众妙之门。

天地之始,阴阳两分,阴尽阳生,阳尽阴生,生可复死,死可复生,一点真诀谓之变,
穷则通,通则变,阴阳逆转,生死交替。


※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 172.16.4.153]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.506毫秒