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

LNK1104 cannot open file 'ifmodintr.lib'

avinashs
新貢獻者 I
8,205 檢視

I have a C++ project in MSVS2017 that references a static Fortran library built in IVF 19.0.2.190. A build error is encountered while running the C++ project: LNK1104 cannot open file 'ifmodintr.lib'. This project was run successfully a few of years ago (2016) with another version of the IVF static lib.

1. How do you include this library in the project path as a default setting?
2. Also, is there a way to "package" this and other required libraries in the static Fortran library?

Any help will be greatly appreciated. 

0 積分
1 解決方案
Steve_Lionel
榮譽貢獻者 III
8,205 檢視

See https://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications

No, you can't package the Intel libraries in your own.

在原始文章中檢視解決方案

10 回應
Steve_Lionel
榮譽貢獻者 III
8,206 檢視

See https://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications

No, you can't package the Intel libraries in your own.

avinashs
新貢獻者 I
8,205 檢視

Thanks. The steps outline in the link fixed the problem. As a point of clarification, if the Fortran static library has various versions (Debug/Release and IA-32/Intel64), can VS2017 be configured to automatically link to the correct one?

Steve_Lionel
榮譽貢獻者 III
8,205 檢視

For mixed-language applications the best approach is to set the Fortran static library project property Fortran > Libraries > Disable default library search rules > Yes. This means that you will need to add the names of the Intel Fortran run-time libraries in Linker > Additional Dependencies in your C main project. The reason you can't mix sets is that C/C++ cares at compile-time which set you use - Fortran doesn't. (If the main program is Fortran, then it will pull in the appropriate libraries.)

Instead of manually adding the library names to the C++ project, if there is an object from your library that is always used, you can add OBJCOMMENT directives to specify the Fortran libraries. From the Fortran perspective, the debug and release libraries are the same. So you'd add the following lines to the relevant source(s):

!DIR$ OBJCOMMENT LIB:"ifconsol.lib"
!DIR$ OBJCOMMENT LIB:"libifcoremd.lib"
!DIR$ OBJCOMMENT LIB:"libifportmd.lib"
!DIR$ OBJCOMMENT LIB:"libmmd.lib"
!DIR$ OBJCOMMENT LIB:"ifmodintr.lib"

This should handle most cases. If you do this, you must disable default library search rules in the library project.

JohnNichols
傑出貢獻者 III
7,934 檢視

FortranFan suggested in a post this morning that the Fortran Lang Discourse as a good site to follow. 

I had a  quick look at the site and there was a simple Fortran program on trees. It looked interesting so I grabbed the code. It is attached.

But I got a ifmodintr.lib missing link error.  It was easy to fix. but why does a simple Fortran program need a mixed programming fix? 

 

Steve_Lionel
榮譽貢獻者 III
7,922 檢視

Normally, you don't need a fix. If the compiler is installed properly, ifmodintr.lib should be found with the default set of library directories. Where you can get into trouble is if the main program is not Fortran and you have not set up the library paths for the other language. Another thing I have seen is where people have set their environment to point to an ancient version of the Intel libraries where ifmodintr.lib didn't exist.

JohnNichols
傑出貢獻者 III
7,912 檢視

Intel® Fortran Compiler – toolkit version: 2021.1-beta10, extension version 19.2.0060.16, Package ID: w_oneAPI_2021.1.2288, Copyright © 2002-2020 Intel Corporation. All rights reserved.
* Other names and brands may be claimed as the property of others.

Created new project in visual studio 2019 preview 

added the Fortran code to main program unit

error repeated.

added C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\ia32_win

to linker additional library directories 

still seems weird?

Steve_Lionel
榮譽貢獻者 III
7,904 檢視

Your program links fine for me in VS2019 and the oneAPI compiler.

This is what I have under Libraries:

$(VSInstallDir)VC\Tools\MSVC\$(VCToolsVersion)\lib\x86
$(UniversalCRTSdkDir)Lib\$(UCRTVersion)\um\x86
$(UniversalCRTSdkDir)Lib\$(UCRTVersion)\ucrt\x86
$(IFortInstallDir)compiler\lib\ia32_win
$(IFortInstallDir)..\..\..\mkl\latest\lib\ia32
$(VSInstallDir)VC\Tools\MSVC\$(VCToolsVersion)\atlmfc\lib\x86
$(WindowsSdkDir)lib\winv6.3\um\x86
$(FrameworkSDKDir)lib
Petr_Parik
新手
5,135 檢視

How to solve this in the newest oneAPI 2023.2 (command line, not VS IDE)?

1. Run "x64 Native Tools Command Prompt for VS 2022" from the Start Menu

2. Change to project working directory

3. Run '%ONEAPI_ROOT%\setvars.bat'

4. ifort complains during compilation it cannot find ifmodintr.lib and ifconsol.lib

It worked normally in older oneAPI versions by running 'compilervars.bat intel64'.

Thanks for any advice.

Steve_Lionel
榮譽貢獻者 III
5,125 檢視

This sequence works when I try it. Please copy and paste the command prompt session from start to end. Also add a "SET LIB" command so I can see what's there.

Petr_Parik
新手
5,104 檢視

Okay, I made a mistake of overwriting the LIB variable inside the compilation batch. After the correction the linker complained it can't find kernel32.lib , so I installed W10 SDK. It works!

Thank you

 

回覆