Hello, I would like to know how to address the following problem: MATLAB gives "The specified module could not be found." when I run a MEX file. Let us divide in a few quick sections my problem to explain it better.
- Original code (stand alone, no MEX): I compiled with the Intel compiler using the following command on the intel oneAPI cmd:
ifort -O3 -Qmkl=parallel test.for -o test
When I run "test.exe", it produces the expected result
[MEX files] I compiled a simple gateway routine that calls the subroutines compiled above. I will show the steps I wook and the solutions I found so far:
ERROR 1:
"error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MKL_SERVICE]"
SOLUTION 1: Add complementary flag "-Qmkl"
mex COMPFLAGS='$COMPFLAGS -O2 -Qmkl' test.f90
I used the -O2 optimization flag here instead of -O3 (as in the first code snippet) because it seems MATLAB only supports that.
The previous error was solved, but...
ERROR 2:
"LINK : fatal error LNK1104: cannot open file 'mkl_intel_ilp64_dll.lib'"
SOLUTION 2: Include folder with .lib files.
mex COMPFLAGS='$COMPFLAGS -O2 -Qmkl' test.f90 '-LC:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\lib\intel64\'
Now, the code does compile (the added path contains the needed .lib files)!
ERROR 3: When I call the function in the form y = test(x), it throws the error:
"The specified module could not be found."
CAUSE OF ERROR 3: I debbuged line by line and found that the problem is when I calls the function pardiso (in the FORTRAN code):
SOLUTION 3 (not working yet): I googled this error, and there are many who had similar problems, but I could not make it work, some of which I show below:
- This person had a similar problem, but without answers
- The same person posted a solution, but it did not work for me (also, he used a previous version of the Intel compiler, with a slightly different syntax)
- The accepted answer to this question suggested using Dependency Walker, which I tried, but my computer is taking over 1 hour to load everything with no success (should I keep trying this method?)
Lastly, I want to mention that I tried also using the flag "-I" to include the "include" folders that contain the "mkl_service" module, in the form:
mex COMPFLAGS='$COMPFLAGS -O2 -Qopenmp -Qmkl' ...
'-IC:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\include' ...
'-LC:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\lib\intel64' ...
'-IC:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\include\intel64\ilp64' ...
'-LC:\Program Files (x86)\Intel\oneAPI\mkl\2023.2.0\lib\intel64\' ...
But all yield the same problem (module could not be found).
I apologize for the long question and appreciate any support!