fortran matlab

Hi, I am trying to run mex files on matlab, I got intel fortran to work (somehow) but now I am getting an error message when running the mex command. Here is what I get (sorry for some german terms in there), any idea what could be wrong?
mex -v yprimef.F
***************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
****************************************************************************
-> Default options filename found in D:\Users\Michael\AppData\Roaming\MathWorks\MATLAB\R2012a
----------------------------------------------------------------
-> Options file = D:\Users\Michael\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2012a
-> COMPILER = ifort
-> Compiler flags:
COMPFLAGS = /fpp /Qprec "/IC:\Program Files\MATLAB\R2012a/extern/include" -c -nologo -DMATLAB_MEX_FILE /fixed /MD /fp:source /assume:bscc
OPTIMFLAGS = /O2 /DNDEBUG
DEBUGFLAGS = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:MEXFUNCTION /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"D:\TEMP\mex_iU7hRj\templib.x" /MAP:"yprimef.mexw64.map" /NOLOGO /manifest /INCREMENTAL:NO
LINKDEBUGFLAGS = /debug /PDB:"yprimef.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"yprimef.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> ifort /fpp /Qprec "/IC:\Program Files\MATLAB\R2012a/extern/include" -c -nologo -DMATLAB_MEX_FILE /fixed /MD /fp:source /assume:bscc /FoD:\TEMP\mex_iU7hRj\yprimef.obj /O2 /DNDEBUG -DMX_COMPAT_32 yprimef.F
Contents of D:\TEMP\mex_iU7hRj\mex_tmp.rsp:
D:\TEMP\mex_iU7hRj\yprimef.obj
--> link /out:"yprimef.mexw64" /dll /export:MEXFUNCTION /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"D:\TEMP\mex_iU7hRj\templib.x" /MAP:"yprimef.mexw64.map" /NOLOGO /manifest /INCREMENTAL:NO @D:\TEMP\mex_iU7hRj\mex_tmp.rsp
LINK : error LNK2001: Nicht aufgelöstes externes Symbol "MEXFUNCTION".
D:\TEMP\mex_iU7hRj\templib.x : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Link of 'yprimef.mexw64' failed.

1 个评论

Did you resolve your previous question http://www.mathworks.com/matlabcentral/answers/37926-intel-fortran-matlab-2012a

请先登录,再进行评论。

 采纳的回答

Kaustubha Govind
Kaustubha Govind 2012-5-9

0 个投票

Seems like a permissions/UAC issue. Are you running the command from a directory that you have write access to? Also, try copying yprimef.F to a location in your home directory so that the MEX command doesn't attempt to write to the MATLAB installation root (inside C:\Program Files). If that still doesn't work, try starting MATLAB as Administrator and run the command.

4 个评论

actually, this error message is probably related to my other post:
http://mathworks.com/matlabcentral/answers/37926-intel-fortran-matlab-2012a#answer_47312
I change some references in the mexopts.bat file that matlab uses to link to the compiler. Turns out that it was partially correct I guess as I did not get the error message 'can't find compiler' anymore but the one that I posted above.
Note, when I search for compiler I get offered
[1] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
If I choose that option then I can run mex yprime.c just fine. Unfortunately I need to get intel fortran to run but sth appears to be wrong.
thanks for the help.
here is my mexopts.bat file:
@echo off
rem INTELF12MSVS2010OPTS.BAT
rem
rem Compile and link options used for building MEX-files using the
rem Intel? Fortran Compiler 12.0 with the Microsoft? Visual Studio?
rem 2010 SP1 Professional Edition linker.
rem
rem StorageVersion: 1.0
rem FortrankeyFileName: INTELF12MSVS2010OPTS.BAT
rem FortrankeyName: Intel Visual Fortran
rem FortrankeyManufacturer: Intel
rem FortrankeyVersion: 12.0
rem FortrankeyLanguage: Fortran
rem
rem $Revision: 1.1.6.3 $ $Date: 2011/10/22 18:49:26 $
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************
set MATLAB=%MATLAB%
set IFORT_COMPILER12=C:\Program Files (x86)\Intel\Composer XE 2011 SP1\
set VSINSTALLDIR=%VS100COMNTOOLS%\..\..
set VCINSTALLDIR=%VSINSTALLDIR%\VC
rem In this case, LINKERDIR is being used to specify the location of the SDK
set LINKERDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0
set PATH=%IFORT_COMPILER12%\Bin\Intel64;%VCINSTALLDIR%\bin\amd64;%LINKERDIR%\bin\x64;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%MATLAB_BIN%;%PATH%
set INCLUDE=%IFORT_COMPILER12%\compiler\Include;%LINKERDIR%\include;%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\VCPackages;%INCLUDE%
set LIB=%IFORT_COMPILER12%\compiler\Lib\Intel64;%LINKERDIR%\LIB\x64;%VCINSTALLDIR%\LIB\amd64;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%MATLAB%\extern\lib\win64;%LIB%
set MW_TARGET_ARCH=win64
rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=ifort
set COMPFLAGS=/fpp /Qprec "/I%MATLAB%/extern/include" -c -nologo -DMATLAB_MEX_FILE /fixed /MD /fp:source /assume:bscc
set OPTIMFLAGS=/O2 /DNDEBUG
set DEBUGFLAGS=/Z7
set NAME_OBJECT=/Fo
rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win64\microsoft
set LINKER=link
set LINKFLAGS=/dll /export:MEXFUNCTION /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map" /NOLOGO /manifest /INCREMENTAL:NO
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@
rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res"
set RC_LINKER=
set POSTLINK_CMDS=del "%LIB_NAME%.x" "%LIB_NAME%.exp"
set POSTLINK_CMDS1=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%";2 -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS2=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.map"
Michael: I do think it is a UAC issue because the error about templib.x occurs after linking is complete - the MEX file is typically generated in a temporary location and then copied to the actual destination, which is when the error seems to occur. A similar suggestion about starting as admin solved the same problem previously: http://www.mathworks.com/matlabcentral/answers/17691-yprime-c-to-mex-compile-error-using-mex-at-208
thanks for the advice. I ran it as administrator and it didn't help. When I set it to c++ compiler via mex -setup and let matlab search, it finds it, i choose it and I can run mex yprime.c without problem. Thus this must be a different issue with the intel fortran
Oops, just noticed the "Unresolved external symbol" error in your question. Sorry, this missed my eye because it was in German. It looks like the issue is not the compiler, but your MEX-file yprimef.F - is there a function called mexFunction defined in it? This function is required as an entry-point in MEX-function.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by