Why do I get "LNK1104: cannot open file 'ifmodintr.lib'" using "mex" with a Fortran file?
조회 수: 8 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2024년 5월 29일
편집: MathWorks Support Team
2024년 5월 29일
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?
채택된 답변
MathWorks Support Team
2024년 5월 29일
편집: MathWorks Support Team
2024년 5월 29일
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
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!