在Fortran MEX中使用Intel MKL

要想成功编译使用Intel MKL的FortranMEX文件,需要修改mexopts.bat中的几个地方。以IVF11为例,需要修改的地方如下:

  1. setINCLUDE=%IFORT_COMPILER11%\Include;%IFORT_COMPILER11%\Include\IA32;%IFORT_COMPILER11%\mkl\Include;%IFORT_COMPILER11%\mkl\Include\IA32;%LINKERDIR%\VC\ATLMFC\INCLUDE;%LINKERDIR%\VC\INCLUDE;%WINSDKDIR%\include;%LINKERDIR%\SDK\v3.5\include;%INCLUDE%

  2. setLIB=%IFORT_COMPILER11%\Lib\IA32;%IFORT_COMPILER11%\mkl\ia32\lib;%LINKERDIR%\VC\ATLMFC\LIB;%LINKERDIR%\VC\LIB;%WINSDKDIR%\Lib;%LINKERDIR%\SDK\v3.5\lib;%MATLAB%\extern\lib\win32;%LIB%

  3. set COMPFLAGS=/fpp /Qprec"/I%MATLAB%/extern/include" -c -nologo -DMATLAB_MEX_FILE /MD/fp:source /assume:bscc /QxHost /Qmkl

上面红色部分是需要添加的。

如果Link过程中出现“无法解析的外部符号 _xxxxxx,该符号在函数 _xxxxx中被引用”之类的错误,是因为Linker没有找到合适的.lib文件,可如下处理:

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 /INCREMENTAL:NO

rem Linkable MKL libs:mkl_blacs_dll.libmkl_blacs_intelmpi.lib mkl_blacs_mpich2.lib mkl_blas95.libmkl_cdft_core.lib mkl_cdft_core_dll.lib mkl_core.libmkl_core_dll.lib mkl_intel_c.lib mkl_intel_c_dll.libmkl_intel_s.lib mkl_intel_s_dll.lib mkl_intel_thread.libmkl_intel_thread_dll.lib mkl_lapack95.lib mkl_pgi_thread.libmkl_pgi_thread_dll.lib mkl_scalapack_core.libmkl_scalapack_core_dll.lib mkl_sequential.libmkl_sequential_dll.lib mkl_solver.libmkl_solver_sequential.lib

set LINKFLAGS =%LINKFLAGS% /LIBPATH:"%IFORT_COMPILER11%\mkl\ia32\lib"mkl_lapack95.libmkl_intel_c.lib

将上面黄颜色部分所示的某个.lib 文件添加到LINKFLAGS后面即可,如绿色部分所示。如果实在不知道该加哪个.lib,就全部加上。


出自:http://blog.sina.com.cn/s/blog_6e98932f0100mjqo.html


你可能感兴趣的:(thread,matlab,include,fortran,compiler,linker)