calling mex file error

2 Ansichten (letzte 30 Tage)
msh
msh am 27 Jun. 2014
Bearbeitet: James Tursa am 27 Jun. 2014
Hi,
I am trying to execute an example found in mathworks. The example is very simple:
copyfile(fullfile(matlabroot,'extern','examples','refbook',...
'loadsparse.F'),'.','f');
copyfile(fullfile(matlabroot,'extern','examples','refbook',...
'fulltosparse.F'),'.','f');
mex -largeArrayDims fulltosparse.F loadsparse.F
So indeed those files, where copied in my current folder. But then the following error shows up.
cl : Command line warning D9024 : unrecognized source file type 'fulltosparse.F', object file assumed
cl : Command line warning D9027 : source file 'fulltosparse.F' ignored
cl : Command line warning D9021 : no action performed
C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'fulltosparse.F'
Error using mex (line 206)
Unable to complete successfully.
NOTHING FROM WHAT I FOUND IN PREVIOUS THREADS WORKED.
I have installed the SDK 7.1 as suggested. Indeed, by running the "mex-setup" i can get the following confirmation:
Your machine has a Microsoft Software Development Kit (SDK) compiler located at
C:\Program Files (x86)\Microsoft Visual Studio 10.0. Do you want to use this compiler [y]/n?
And then,
Trying to update options file: C:\Users\Minamar\AppData\Roaming\MathWorks\MATLAB\R2012b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2012b\bin\win64\mexopts\mssdk71opts.bat
Done . . .
So, I am wondering whether the location of the compiler should be somewhere else or not and how I can proceed for fixing this error.
Thanks

Antworten (1)

James Tursa
James Tursa am 27 Jun. 2014
Bearbeitet: James Tursa am 27 Jun. 2014
fulltosparse.F and loadsparse.F are Fortran source files, not C source files. You would need to select a Fortran compiler to mex them. The reason you are getting an "Unrecognized source file type" message is because the C compiler doesn't understand what a .F file is, so it assumes it may be an object file (which it isn't). Try the fulltosparse.c source file instead (from the same folder), which is intended for a C compiler.
  2 Kommentare
msh
msh am 27 Jun. 2014
Bearbeitet: msh am 27 Jun. 2014
Thanks James, but my target is to a run a fortran subroutine. In this case, the SDK alone is not suitable ? Do I also need to install the, Intel Visual Fortran Composer XE 2013 or 2011 for instance ?
For a beginner like me, the matlab information was not very clear if this is the case. Nevertheless, the compatible Intel compilers are not available for free ? what's the solution in this case ?
James Tursa
James Tursa am 27 Jun. 2014
Bearbeitet: James Tursa am 27 Jun. 2014
Yes, you need to install a Fortran compiler since MATLAB does not ship with one. Intel Visual Fortran Composer would be suitable for this (unfortunately they are also expensive). You can check the doc to see which Fortran version(s) are officially supported by the version of MATLAB you have.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by