Why do I get "LNK1104: cannot open file 'ifmodintr.lib'" using "mex" with a Fortran file?
4 次查看(过去 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!