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

Calling Fortran function from Visual C++, get: fatal error LNK1104: cannot open file 'ifmodintr.lib'

Ioannis_K_
New Contributor I
601 Views

Hello,

I am using the Fortran oneAPI Fortran Compiler Classic 2021.1.1 with Visual Studio 2019.

I am trying to call a function in a Fortran static library I have built, from a C++ program.

I combine both projects in a single Visual Studio solution, define the dependencies for the C++ project (= it depends on the Fortran object file).

The fortran library builds first without any problem, the C++ source compiles, but then the linker gives me the following error:

LINK : fatal error LNK1104: cannot open file 'ifmodintr.lib'

 

From my understanding, I need to follow the solution of the following link:

https://www.intel.com/content/www/us/en/developer/articles/technical/configuring-visual-studio-for-mixed-language-applications.html

 

However, this link is out-of-date, as it apparently does not cover Visual Studio 2019 and the oneAPI compilers. I wanted to ask if it is possible for Intel to update the instructions, or if someone can explain which of the previous versions' procedure (and with what changes) will work.

 

0 Kudos
1 Reply
Ron_Green
Moderator
562 Views

Referring to that article, the x64 build library is 

IFORT_COMPILER21, which should evaluate to

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\

Look up the IFORT_COMPILERxx env var, like IFORT_COMPILER21.  TO see you env vars, web search "How do I view environment variables in Windows 11?" or WIndows 10.

Should be that IFORT_COMPILER21, or IFORT_COMPILER22, or IFORT_COMPILER19.  Again, check your Settings, Advanced, Environment Variables to confirm.  I don't have your compiler version on my PC.  It should be something like 

c:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\compiler\windows

 

Include:

you can use $(IFORT_COMPILER21)\compiler\include:$(Include_Path)

 

Lib dir

$(IFORT_COMPILER21)\compiler\lib\intel64:$(LibraryPath)

 

this assumes you are using the Intel64 build for the C++ project. 

 I'll see if one of my Windows saavy colleagues can update that web page you referenced 

0 Kudos
Reply