matlab的版本要到2015b才支持vs2015,然而自己電腦上用的matlab2014a,和VS2015社區版,不想重新安裝,需要替換其mexopts文件夾,估計就類似於一個mex的Makefile文件,路徑為R2014a\bin\win64\mexopts。下載之,替換即可。mexopts文件夾的下載地址為 http://pan.baidu.com/s/1o8hR926 ,之后做以下步驟編譯即可。
>> mex -setup
MEX 配置為使用 'Microsoft Visual C++ 2015 Professional (C)' 以進行 C 語言編譯。
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.
要選擇不同的語言,請從以下選項中選擇一種命令:
mex -setup C++
mex -setup FORTRAN
>> mex -setup C++
MEX 配置為使用 'Microsoft Visual C++ 2015 Professional' 以進行 C++ 語言編譯。
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.
>> mex -v yourfile.cpp