MATLAB Answers

Problem with mex setup for FORTRAN

62 views (last 30 days)
Durga Lal Shrestha
Durga Lal Shrestha on 9 Sep 2014
Commented: Walter Roberson on 26 Dec 2017
I got a error message with
mex -setup FORTRAN.
Error using mex No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2014a/win64.
I am using MATLAB R2014a in Windows 64 bit. I have Intel Visual Fortran Composer XE 2013 in Microsoft Visual Studio 2010 Shell and in Microsoft Visual Studio 2008 Professional Edition.
I tried with C language and do not have any problem.
Thanks. Durga

  4 Comments

Show 1 older comment
Durga Lal Shrestha
Durga Lal Shrestha on 15 Sep 2014
Supported and Compatible Compilers – Release 2014a shows that Intel Visual Fortran Composer XE 2013 is supported in MATLAB R2014a. But in my case I do not understand why I cannot setup mex for FORTRAN.
Geoff Hayes
Geoff Hayes on 15 Sep 2014
What happens if you just run mex -setup? Do you see a list of available compilers?
Durga Lal Shrestha
Durga Lal Shrestha on 15 Sep 2014
This is what I got with
mex -setup
MEX configured to use 'Microsoft Visual C++ 2008 (C)' for C language compilation. Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 16 Sep 2014
Edited: Geoff Hayes on 16 Sep 2014
Durga - This is more of a Fortran for Mac answer, but as the behaviour is like yours, I think that you will have to do something similar.
I downloaded the Fortran compiler for my Mac (GNU gfortan), installed the package, ran
mex -setup FORTRAN
and observed a similar error as you
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2014a/maci64.
Running the same with verbose mode enabled I observed
>> mex -setup -v FORTRAN
Verbose mode is on.
... Looking for compiler 'gfortran' ...
... Executing command 'which gfortran' ...No.
... Looking for file '/usr/local/bin/gfortran' ...Yes.
... Looking for folder '/usr/local/bin' ...Yes.
... Executing command 'which gfortran' ...No.
... Looking for file '/usr/local/bin/gfortran' ...Yes.
... Executing command 'gfortran -print-file-name=libgfortran.dylib' ...No.
Did not find installed compiler 'gfortran'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2014a/maci64.
So the setup runs the command which gfortran. This is not the MATLAB function which but the UNIX version to locate the executable (MATLAB is probably executing system('which gfortran') to find it). The UNIX which uses the PATH environment variable to find the file it is looking for. This suggests that I have to update the PATH variable with the path to gfortran.
If I update the PATH environment variable
setenv('PATH', [getenv('PATH') ':/usr/local/gfortran/bin']);
and then re-run the setup, I observe
>> mex -setup -v FORTRAN
Verbose mode is on.
... Looking for compiler 'gfortran' ...
... Executing command 'which gfortran' ...Yes ('/usr/local/gfortran/bin/gfortran').
<etc.>
Found installed compiler 'gfortran'.
Copied options file from '/Applications/MATLAB_R2014a.app/bin/maci64/mexopts/gfortran.xml' to
'/Users/geoff/.matlab/R2014a/mex_FORTRAN_maci64.xml'.
MEX configured to use 'gfortran' for FORTRAN language compilation.
The above is not ideal because I have to run the setenv('PATH', [getenv('PATH') ':/usr/local/gfortran/bin']); command, so an alternative to this (that updates the PATH once) needs to be found.
So you should try the same - re-run the mex setup with verbose mode enabled and observe the output. You may need to update a similar PATH environment variable with the location of your Fortran compiler executable.

  5 Comments

Show 2 older comments
Durga Lal Shrestha
Durga Lal Shrestha on 16 Sep 2014
Copying those folders from Microsoft Visual Studio 9.0 to 10 passes that point, but
Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A' InstallationFolder ...No.
It seems I need to install Windows SDK 7.1 and have tried but failed to install. I googled and found that I need to uninstall Microsoft Visual C++ 2010 before installing SDk ( <http://www.mathworks.com.au/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system SDK 7.1 installation fail >
Now I give up fixing this issue in my pc as I found another pc in network where I can generate fortran mex file.
Alec Jacobson
Alec Jacobson on 26 Dec 2017
I'm on Mac but after issuing
mex -setup -v FORTRAN
I only see
Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER17' ...No.
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Looking for environment variable 'IFORT_COMPILER14' ...No.
... Looking for environment variable 'IFORT_COMPILER13' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran Composer XE'.
And changing the PATH variable did not help. Any suggestions?

Sign in to comment.