06-17-2025 09:43 AM
I am building our LabWindows program using CMakeLists.txt inside Visual Studio. I am getting this warning:
warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
According to the always-accurate AI of CoPilot:
"The LNK4098 warning occurs when MSVC runtime libraries conflict—typically when mixing static (/MT) and dynamic (/MD) runtime linking. Since you're linking against LabWindows libraries, they likely use a different runtime setting than your compiled .C files."
The libraries I am linking with are:
target_link_libraries(OurProgram PRIVATE
# LabWindows libraries:
"C:/Program Files (x86)/National Instruments/CVI2017/extlib/msvc64/cviauto.lib"
"C:/Program Files (x86)/National Instruments/CVI2017/extlib/msvc64/cvirt.lib"
"C:/Program Files (x86)/National Instruments/CVI2017/extlib/msvc64/cvisupp.lib"
)
"ExtLib" makes me think external, like a DLL. But I do not know what is under-the-hood of LabWindow's runtime.
The AI says I should add one of these:
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") # Equivalent to /MD
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") # Equivalent to /MT
Or add something to ignore the warning.
Any insight would be appreciated.
07-31-2025 01:09 AM
This usually means you're mixing static and dynamic C runtime libraries—e.g., linking your code with /MT (static CRT = LIBCMT) while one of the linked libraries (like a LabWindows library) uses /MD (dynamic CRT = MSVCRT.lib), or vice versa.
07-31-2025 08:06 AM
@dustin857mark wrote:
This usually means you're mixing static and dynamic C runtime libraries—e.g., linking your code with /MT (static CRT = LIBCMT) while one of the linked libraries (like a LabWindows library) uses /MD (dynamic CRT = MSVCRT.lib), or vice versa.
Any suggestions on how I can tell? We link to the LabWindows libraries, and FTDI libraries (which are provided in both static linked and ones that use their DLL), plus whatever default ones Windows uses.
Unfortunately, my career has been in embedded C programming and the last PC I personally owned was 2001, so my Windows exposure is pretty limited beyond my current job.