Clear Filters
Clear Filters

Why do I get "LNK1104: cannot open file 'ifmodintr.lib'" using "mex" with a Fortran file?

13 views (last 30 days)
I am using MATLAB R2024a on a Windows machine to build and link a C++ MEX function to a Fortran object file. The "mex" function is using Microsoft Visual C++ 2022 as a compiler, and the Fortran object file was compiled using the Intel oneAPI 2024 for Fortran compiler.
When a run the "mex" function, I get the following error
>> mex myMexFunction.cpp myFortranObject.obj
Building with 'Microsoft Visual C++ 2022'.
Error using mex
LINK : fatal error LNK1104: cannot open file 'ifmodintr.lib'
How can I resolve this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 May 2024 at 0:00
Edited: MathWorks Support Team on 29 May 2024 at 19:33
The "ifmodintr.lib" library is provided by Intel. By default, "mex" is not configured to search for Intel's library files when using the Microsoft Visual C++ compiler.
To resolve this error, you must add the directory that contains the Fortran compiler's library files to the search path used by "mex". This can be done using the "-L" option, which is described in the following documentation page:
For example, the default directory of the library files of the Intel oneAPI 2024 for Fortran compiler is 
C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\lib\
. So, your "mex" command would become:
mex("myMexFunction.cpp", "myFortranObject.obj", ...
"-LC:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\lib\");
For more information on insuring the compatibility of compilers used to build linked libraries and object files with the compiler used to build the "mex" function, see this article:

More Answers (0)


Find more on Fortran with MATLAB in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!