Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort /dll link error LNK4098

drschn15456
Beginner
419 Views

Our Windows 7 64-bit application was built with Intel Composer XE 2013 Update 1 (package 119) using the command

ifort  /dll  /real-size:128  /double-size:128  application.f  dlsode.f

We are upgrading to Windows 10 and Intel Visual Fortran Intel 64 Compiler 19.1.3.311 Build 20201010_000000 and want to compile dlsode.f with a lower optimization level /O1.  Using the commands

ifort  /c  /O1  /real-size:128  /double-size:128  dlsode.f

ifort  /dll  /real-size:128  /double-size:128  application.f  dlsode.obj

I get the link error

LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

According to previous posts in this forum regarding LNK4098, dlsode.obj and application.obj are using different run-time libraries.  When I replaced the first ifort command with

ifort  /c  /O1  /libs:dll  /real-size:128  /double-size:128  dlsode.f

the dll seemed to build correctly and executed correctly.  Was this the correct solution?  What is the correct solution using the /NODEFAULTLIB option?

 

Labels (1)
0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
400 Views

Yes, using /libs:dll consistently was the correct choice. /NODEFAULTLIB is almost always the wrong choice (despite the claim in the error message.)

What you have is what DEC (now Intel) developer Lorri Menard called "MCLS" or "Mixed C Library Syndrome". Her original Visual Fortran Newsletter article on the topic is no longer around, but the concept remains. Unlike the Intel Fortran support libraries, the Microsoft Visual C/C++ libraries don't like being mixed, with debug and non-debug versions combined, or similarly static and DLL. The reason is that the MSVC compiler generates different code depending on which library type you specify. Since the Fortran support library is written in C, that issue carries over to Fortran builds. (Intel Fortran doesn't generate different code for these cases.)

 

View solution in original post

2 Replies
Steve_Lionel
Black Belt Retired Employee
401 Views

Yes, using /libs:dll consistently was the correct choice. /NODEFAULTLIB is almost always the wrong choice (despite the claim in the error message.)

What you have is what DEC (now Intel) developer Lorri Menard called "MCLS" or "Mixed C Library Syndrome". Her original Visual Fortran Newsletter article on the topic is no longer around, but the concept remains. Unlike the Intel Fortran support libraries, the Microsoft Visual C/C++ libraries don't like being mixed, with debug and non-debug versions combined, or similarly static and DLL. The reason is that the MSVC compiler generates different code depending on which library type you specify. Since the Fortran support library is written in C, that issue carries over to Fortran builds. (Intel Fortran doesn't generate different code for these cases.)

 
drschn15456
Beginner
394 Views

Steve,

Thank you very much for your prompt and thorough reply.

Reply