Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

Intel(R) Parallel Studio XE 2017 to create FORTRAN mex files in MATLAB

Abhishek_S_1
Beginner
677 Views
 
I downloaded Parallel Studio XE 2017 and created FORTRAN mex files in MATLAB however I ran into an error when I tried to run the mex file.
The MATLAB error is:
 
Invalid MEX-file 'C:\Users\User\Desktop\masters thesis\lrhb\LRHB.mexw64':
Missing symbol 'for_realloc_lhs' in 'C:\Program Files\MATLAB\R2017a/bin/win64\libifcoremd.dll' required by 'C:\Users\User\Desktop\masters
thesis\lrhb\LRHB.mexw64'. 
 
In the Intel folder ' C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\compiler\lib\intel64', I see a file named libifcoremd.lib. 
 
Is it possible to obtain the libifcoremd.dll form of libifcoremd.lib file for the Intel package?
There is a libifcoremd.dll file in MATLAB directory however I do not think it is able to perform the functions that are required by a mex file. If there is an option to obtain libifcoremd.dll produced by Intel, I think it should work.
 
0 Kudos
1 Solution
mecej4
Honored Contributor III
677 Views

The Parallel Studio installation should have installed the DLL in the following directory:

     ' C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\redist\intel64\compiler'

However, merely finding the file will not solve your problem. The file libifcoremd.dll in the Matlab bin\win64 directory and the one in the compiler's "redist" branch are probably different versions. In effect, you built the Mex file using the compiler's version, but Matlab attempts to call the routine from its own version. You have to arrange things such that your Mex file finds the "redist" version first, but then there is the risk of Matlab needing to load its own version for purposes unrelated to your Mex file.

You need to ask for advice from the Mathworks about resolving this "multiple DLL versions" issue. I have PS2017U2 and Matlab 2012. The libifcoremd.dll of PS2017 exports for_realloc_lhs, and the one of Matlab does not.

It may occur to you to try replacing the DLL in Matlab's bin directory with the "redist" version, but you should back up the file before doing that, and be prepared for trouble and to roll back the changes, if things don't work out. It would also be useful to know the rules used by Windows for locating and loading a DLL when multiple versions of the DLL exist.

View solution in original post

0 Kudos
2 Replies
mecej4
Honored Contributor III
678 Views

The Parallel Studio installation should have installed the DLL in the following directory:

     ' C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\redist\intel64\compiler'

However, merely finding the file will not solve your problem. The file libifcoremd.dll in the Matlab bin\win64 directory and the one in the compiler's "redist" branch are probably different versions. In effect, you built the Mex file using the compiler's version, but Matlab attempts to call the routine from its own version. You have to arrange things such that your Mex file finds the "redist" version first, but then there is the risk of Matlab needing to load its own version for purposes unrelated to your Mex file.

You need to ask for advice from the Mathworks about resolving this "multiple DLL versions" issue. I have PS2017U2 and Matlab 2012. The libifcoremd.dll of PS2017 exports for_realloc_lhs, and the one of Matlab does not.

It may occur to you to try replacing the DLL in Matlab's bin directory with the "redist" version, but you should back up the file before doing that, and be prepared for trouble and to roll back the changes, if things don't work out. It would also be useful to know the rules used by Windows for locating and loading a DLL when multiple versions of the DLL exist.

0 Kudos
Abhishek_S_1
Beginner
677 Views

mecej4 wrote:

The Parallel Studio installation should have installed the DLL in the following directory:

     ' C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2017.2.187\windows\redist\intel64\compiler'

However, merely finding the file will not solve your problem. The file libifcoremd.dll in the Matlab bin\win64 directory and the one in the compiler's "redist" branch are probably different versions. In effect, you built the Mex file using the compiler's version, but Matlab attempts to call the routine from its own version. You have to arrange things such that your Mex file finds the "redist" version first, but then there is the risk of Matlab needing to load its own version for purposes unrelated to your Mex file.

You need to ask for advice from the Mathworks about resolving this "multiple DLL versions" issue. I have PS2017U2 and Matlab 2012. The libifcoremd.dll of PS2017 exports for_realloc_lhs, and the one of Matlab does not.

It may occur to you to try replacing the DLL in Matlab's bin directory with the "redist" version, but you should back up the file before doing that, and be prepared for trouble and to roll back the changes, if things don't work out. It would also be useful to know the rules used by Windows for locating and loading a DLL when multiple versions of the DLL exist.

Thank you for your reply. I was able to find libifcoremd.dll file in the Intel folder. It was in the folder you mentioned. I replaced it in MATLAB folder and it worked! 

Also, I found a way to change the FORTRAN code for the MATLAb compiler itself to work. All variables in FORTRAN must be allocated properly. For example: If a variable is being assigned as v = w.

It should be v(1:k) = w(1:k) unless it is a scalar.

0 Kudos
Reply