我将从FORTRAN文件(test.f)创建一个mex文件。为此,我已经为我的MATLAB版本(R2016b)安装了兼容的编译器版本。为了确保正确安装了编译器,我应用了以下命令:
mex -v -compatibleArrayDims test.f
答案是:
找到已安装的用于Fortran的编译器'Intel Parallel Studio XE 2015 Microsoft SDK 7.1'。
然后,MATLAB尝试使用以下消息创建mex文件:
设置PATH = C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ bin \ intel64; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ Common7 \ IDE; C:\ Program Files(x86 )\ Microsoft Visual Studio 10.0 \ Common7 \ Tools; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ Bin \ amd64; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ Bin \ VCPackages ; C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ Bin \ x64; C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ Bin ;; C:\ Program Files(x86)\ Common Files \英特尔\共享库\ redist \ intel64 \ mpirt; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ mpirt; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Liaries \ redist \ intel64 \ compiler; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ compiler; C:\ Windows \ system32; C:\ Windows; C:\ Windows \ System32 \ Wbem ; C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \; C:\ Program Files \ Broadcom \ Broadcom 802.11网络适配器\驱动程序; C:\ Program Files(x86)\ ATI Technologies \ ATI.ACE \ Core-Static; C:\ Program档案s \ MATLAB \ R2016b \ runtime \ win64; C:\ Program Files \ MATLAB \ R2016b \ bin; C:\ Program Files \ MATLAB \ R2016b \ polyspace \ bin; C:\ Program Files \ Microsoft Windows Performance Toolkit \ 设置INCLUDE = C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ include; C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ compiler \ include; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ INCLUDE; C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ INCLUDE; C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ INCLUDE \ gl; C:\ Program Files \ MATLAB \ R2016b \ extern \ include ;; 设置LIB = C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ lib \ intel64; C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ compiler \ lib \ intel64; C:\ Program Files(x86 )\ Microsoft Visual Studio 10.0 \ VC \ Lib \ amd64; C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ Lib \ X64; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ ATLMFC \ LIB \ AMD64; C:\ Program Files \ MATLAB \ R2016b \ lib \ win64; C:\ Program Files \ MATLAB \ R2016b \ extern \ lib \ win64; 设置LIBPATH = C:\ Program Files(x86)\ Intel \ Composer XE 2015 \ compiler \ Lib \ Intel64; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ Lib \ amd64; C:\ Program Files \ Microsoft SDK \ Windows \ v7.1 \ LIB \ X64; C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ ATLMFC \ LIB \ AMD64; C:\ Program Files \ MATLAB \ R2016b \ extern \ lib \ win64 ;
Compiler location: C:\Program Files (x86)\Intel\Composer XE 2015
Options file: C:\Program Files\MATLAB\R2016b\bin\win64\mexopts\intel_fortran_15_sdk71.xml
CMDLINE200 : link /nologo /manifest kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /incremental:NO /DLL /EXPORT:MEXFUNCTION C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.obj C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\fortran_mexapi_version.obj /LIBPATH:"C:\Program Files\MATLAB\R2016b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /out:test.mexw64 /MAP:"test.map"
CMDLINE250 : mt -outputresource:test.mexw64;2 -manifest test.mexw64.manifest
CMDLINE300 : del test.exp test.lib "test.map" test.mexw64.manifest test.ilk
COMPILER : ifort
COMPFLAGS : /nologo /fpp /Qprec /fixed /MD /fp:source /assume:bscc -I"C:\Program Files\MATLAB\R2016b\extern\include" /DMX_COMPAT_32 /DMATLAB_MEX_FILE
COMPDEFINES : /DMX_COMPAT_32 /DMATLAB_MEX_FILE
MATLABMEX : /DMATLAB_MEX_FILE
OPTIMFLAGS : /O2 /DNDEBUG
INCLUDE : -I"C:\Program Files\MATLAB\R2016b\extern\include"
DEBUGFLAGS : /Z7
LINKER : link
LINKFLAGS : /nologo /manifest kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /incremental:NO
LINKTYPE : /DLL
LINKEXPORT : /EXPORT:MEXFUNCTION
LINKLIBS : /LIBPATH:"C:\Program Files\MATLAB\R2016b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib
LINKDEBUGFLAGS : /debug /PDB:"test.mexw64.pdb"
LINKOPTIMFLAGS :
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=ifort
set COMPFLAGS=/c /nologo /fpp /Qprec /fixed /MD /fp:source /assume:bscc -I"C:\Program Files\MATLAB\R2016b\extern\include" /DMX_COMPAT_32 /DMATLAB_MEX_FILE /DMX_COMPAT_32 /DMATLAB_MEX_FILE /DMATLAB_MEX_FILE
set OPTIMFLAGS=/O2 /DNDEBUG
set DEBUGFLAGS=/Z7
set LINKER=link
set LINKFLAGS=/nologo /manifest kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /incremental:NO /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\MATLAB\R2016b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /EXPORT:MEXFUNCTION
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
FORTRANROOT : C:\Program Files (x86)\Intel\Composer XE 2015
SDKROOT : C:\Program Files\Microsoft SDKs\Windows\v7.1\
VSROOT : C:\Program Files (x86)\Microsoft Visual Studio 10.0
MATLABROOT : C:\Program Files\MATLAB\R2016b
ARCH : win64
SRC : "C:\Users\Novin Pendar\Desktop\WD2007-Final\test.f";"C:\Program Files\MATLAB\R2016b\extern\version\fortran_mexapi_version.F"
OBJ : C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.obj;C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\fortran_mexapi_version.obj
OBJS : C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.obj C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\fortran_mexapi_version.obj
SRCROOT : C:\Users\Novin Pendar\Desktop\WD2007-Final\test
DEF : C:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.def
EXP : test.exp
LIB : test.lib
EXE : test.mexw64
ILK : test.ilk
MANIFEST : test.mexw64.manifest
TEMPNAME : test
EXEDIR :
EXENAME : test
OPTIM : /O2 /DNDEBUG
LINKOPTIM :
CMDLINE100_0 : ifort /c /nologo /fpp /Qprec /fixed /MD /fp:source /assume:bscc -I"C:\Program Files\MATLAB\R2016b\extern\include" /DMX_COMPAT_32 /DMATLAB_MEX_FILE /O2 /DNDEBUG "C:\Users\Novin Pendar\Desktop\WD2007-Final\test.f" /FoC:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.obj
使用“带有Microsoft SDK 7.1的Fortran的Intel Parallel Studio XE 2015构建”。 ifort / c / nologo / fpp / Qprec / fixed / MD / fp:source / assume:bscc -I“ C:\ Program Files \ MATLAB \ R2016b \ extern \ include” / DMX_COMPAT_32 / DMATLAB_MEX_FILE / O2 / DNDEBUG“ C:\ Users \ Novin Pendar \ Desktop \ WD2007-Final \ test.f“ /FoC:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\test.obj ifort / c / nologo / fpp / Qprec / fixed / MD / fp:source / assume:bscc -I“ C:\ Program Files \ MATLAB \ R2016b \ extern \ include” / DMX_COMPAT_32 / DMATLAB_MEX_FILE / O2 / DNDEBUG“ C:\程序文件\ MATLAB \ R2016b \ extern \ version \ fortran_mexapi_version.F“ /FoC:\Users\NOVINP~1\AppData\Local\Temp\mex_2486250744236_2948\fortran_mexapi_version.obj 链接/ nologo / manifest kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib / incremental:NO / DLL / EXPORT: MEXFUNCTION C:\ Users \ NOVINP〜1 \ AppData \ Local \ Temp \ mex_2486250744236_2948 \ test.obj C:\ Users \ NOVINP〜1 \ AppData \ Local \ Temp \ mex_2486250744236_2948 \ fortran_mexapi_version.obj / LIBPATH:“ C:\ Program Files \ MATLAB \ R2016b \ extern \ lib \ win64 \ microsoft“ libmx.lib libmex.lib libmat.lib /out:test.mexw64 /MAP:"test.map”
但是,最终出现以下错误:
使用mex时出错 链接:错误LNK2001:无法解析的外部符号MEXFUNCTION test.lib:致命错误LNK1120:1个未解决的外部因素