Linker Tools Warning LNK4098

博客围绕Linker Tools Warning LNK4098展开,指出该警告是因尝试链接不兼容库所致,如在同一程序中使用不同类型或调试与非调试版本的运行时库。建议编译所有源文件使用相同运行时库,还介绍了用/VERBOSE:LIB开关确定链接库及忽略错误库的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 mixing different types. You’ll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. For example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning. You should compile all source files to use the same run-time library. See the Use Run-Time Library (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 tab of the Settings dialog box in Developer’s Studio or by using the /NODEFAULTLIB:library option with LINK for each library 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 which run-time library you want to use.

To use this run-time libraryIgnore these libraries
Single-threaded (libc.lib)libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, 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, libcmtd.lib, msvcrtd.lib
Debug Single-threaded (libcd.lib)libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib
Debug Multithreaded (libcmtd.lib)libc.lib, libcmt.lib, msvcrt.lib, libcd.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 executable 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.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB
写程序看到 warning,感觉不爽。 这个警告在 link option 中 加入 对应的 /NODEFAULTLIB:xxx.lib   就ok了


上述程序导入出现以下报错,如何解决 Setting Post Processing and Surfaces information ... Done. Copy "C:\Users\XingFU\Desktop\k-w.c" to "libudf\src" Creating user_nt.udf file for 3ddp_host ... Copyright 1987-2024 ANSYS, Inc. All Rights Reserved. Compiler and linker: Microsoft Visual C++ # Generating ud_io1.h k-w.c ..\..\src\k-w.c(1): warning C4819: ??????????????????????(936)?��????????????????????? Unicode ????????????? # Generating udf_names.c because of makefile k-w.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj k-w.obj ????????? libudf.lib ????? libudf.exp k-w.obj : error LNK2019: ??????????????? NEARLY_ZERO?????? inlet_velocity ????????��??? libudf.dll : fatal error LNK1120: 1 ????????????????? NMAKE : U1077: ??link -nologo /Libpath:"E:\Program Files\ANSYS Inc\v242\fluent"\fluent24.2.0\win64\3ddp_host /Libpath:"E:\Program Files\ANSYS Inc\v242\fluent"\fluent24.2.0\multiport\win64\net\shared /dll /out:libudf.dll udf_names.obj k-w.obj mport.lib fl2420.lib ??: ???????0x460?? Stop. Creating user_nt.udf file for 3ddp_node ... Copyright 1987-2024 ANSYS, Inc. All Rights Reserved. Compiler and linker: Microsoft Visual C++ # Generating ud_io1.h k-w.c ..\..\src\k-w.c(1): warning C4819: ??????????????????????(936)?��????????????????????? Unicode ????????????? # Generating udf_names.c because of makefile k-w.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj k-w.obj ????????? libudf.lib ????? libudf.exp k-w.obj : error LNK2019: ??????????????? NEARLY_ZERO?????? inlet_velocity ????????��??? libudf.dll : fatal error LNK1120: 1 ????????????????? NMAKE : U1077: ??link -nologo /Libpath:"E:\Program Files\ANSYS Inc\v242\fluent"\fluent24.2.0\win64\3ddp_node /Libpath:"E:\Program Files\ANSYS Inc\v242\fluent"\fluent24.2.0\multiport\win64\mpi\shared /dll /out:libudf.dll udf_names.obj k-w.obj mport.lib fl_mpi2420.lib ??: ???????0x460?? Stop. Done. NICE-LXF: Opening library "F:\56\56_files\dp0\FFF\Fluent\libudf"... ERROR: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). ���������������������� F:\\56\\56_files\\dp0\\FFF\\Fluent\\libudf\\win64\\3ddp_host\\libudf.dll Done. NICE-LXF: Opening library "F:\56\56_files\dp0\FFF\Fluent\libudf"... ERROR: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). ���������������������� F:\\56\\56_files\\dp0\\FFF\\Fluent\\libudf\\win64\\3ddp_node\\libudf.dll Error: An error or interrupt occurred in the previous operation. Details have been printed to the text console transcript. Error Object: #f
最新发布
07-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值