装了visual studio 2015,可是在matlab中调用失败了。
>> mex -setup
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/win64.html.
尝试去装SDK,还是不行。下面介绍一个可行的方法,也许对你有用。
下载gnumex,地址:https://sourceforge.net/projects/gnumex/?source=typ_redirect 下载Rtools,一个开发R语言的工具,地址:https://cran.r-project.org/bin/windows/Rtools/,下载好后安装。 下载Cygwin,地址:https://www.cygwin.com/,下载好后安装。 将gnumex解压到matlab目录下,并将matlab的目录切换到该文件的主目录下。在matlab的命令行中输入:
>> gnumex
会弹出一个GUI 框:
安装图中的选择好目录,最后点击Make options file,稍作等待几分钟,就OK了。
看结果:
>> mex -setup
Warning: Legacy MEX infrastructure is provided for compatibility; it will be removed in a future
version of MATLAB. For more information, consult the MEX release notes
http://www.mathworks.com/help/matlab/release-notes.html.
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2015a/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] gcc in D:\Rtools\GCC-46~1.3\bin
[0] None
Compiler: 1
Please verify your choices:
Compiler: gcc
Location: D:\Rtools\GCC-46~1.3\bin
Are these correct [y]/n? y
Trying to update options file: C:\Users\mingzi\AppData\Roaming\MathWorks\MATLAB\R2015a\mexopts.bat
From template: F:\matlab\bin\win64\mexopts\GNUMEXOPTS.bat
Done . . .
**************************************************************************
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
Building with the -largeArrayDims option enables the new API.
**************************************************************************
上面有些地方需要做出选择,根据情况来选择即可。