Echeban
Echeban

Reputation: 204

How to solve LNK4098 warning, libcmt.lib conflicts with libraries? and subsequent erroneous results

I need to produce a static .exe to distribute to users that have no VisualStudio, no Intel Fortran/oneAPI, and no MKL.

My code "UgensTester.f90" worked fine since 2010 with yearly updates, no problem, until I decided to replace static arrays by allocatable arrays, like this:

Before.

integer, parameter :: n=8
double precision var(n,3)

Now.

integer n
double precision, allocatable, var(:,:)
read(1,*) n
allocate( var(n,3) )

In VS 2019 > Project > Properties, Fortran oneAPI 2023 > Libraries, I have selected what I need to produce a static .exe and to use MKL. Namely,

Runtime Library: Debug Multithreaded (/libs:static /threads /dbglibs)
Intel Math Kernel Library: Sequential (/Qmkl:sequential)

Linking in Debug mode, I can make a static .exe and the results are fine, but execution is slow.

Linking in Release mode, I get LNK4098 warning, libcmt.lib conflicts with other(?) libraries (which ones?).

It is just a warning, but now the .exe is using is the wrong MKL routines, and I get errors from MKL itself, which my code catches and prints to a file.

I found this explanation online: libcmt.lib. Statically links the native CRT startup into your code.

What can I do to link in Release mode without linking warnings and execution errors. Thank you.

Upvotes: 0

Views: 42

Answers (1)

Ry8ics
Ry8ics

Reputation: 11

I got the warning "LNK4098: defaultlib 'libcmt.lib' conflicts with ..." I just added /NODEFAULTLIB:libcmt.lib under the property page "Linker\Command Line\Additional Options". The warning vanished and the program worked. Note that with several projects linked into the same application each individual project must use the same runtime library.

Upvotes: 1

Related Questions