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

7 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 29 Mag 2024
Modificato: MathWorks Support Team il 29 Mag 2024
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: https://www.mathworks.com/matlabcentral/answers/2123826-can-i-link-a-library-or-ojbect-file-built-with-one-compiler-to-a-mex-function-built-with-a-different

Più risposte (0)

Categorie

Scopri di più su Fortran with MATLAB in Help Center e File Exchange

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by