(转)Matlab R2014a 64位与Visual Studio2015的mex相关问题

https://blog.csdn.net/shwan_ma/article/details/55656175

由于C语言的高效性,在matlab中会经常需要调用C语言的衍生程序,所以用到mex。但是mex -setup中,MatlabR2014a在官方给出的文档中,最高仅支持到VS2013。这让用VS2015和MatlabR2014a的我们会很头疼的一件事情。然而网上对这一方面的资料的好像比较少,通过google和各种百度,整理下面方法供大家参考一下

本文给出的方法仅仅面对***MatlabR2014a 64位 与 Visual Studio2015,win10*** 环境

当mex -setup(注意存在空格)时,弹出:

Error using mex No supported compiler or SDK was found. For options,
visit http://www.mathworks.com/support/compilers/R2014a/win64.

那么打开下面网址则可看到:
这里写图片描述

打开相应版本的supported compilers的detail,选择下载下面的win sdk
这里写图片描述

当安装完SDK后,再在matlab中敲入 mex -setup,则会弹出warning,显示没有合适的compilers。(应该类似下图,当时我忘记截图了,囧)

>> mex -setup
 Warning: Windows SDK 7.1 appears to be installed, but its compiler was not found. Install .NET Framework 4.0, and then rerun the SDK installation to add the "Visual C++ Compilers" component. See http://www.mathworks.com/support/solutions/en/data/1-IB1G3Q/ for more information.
 Error using mex
 No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler. For more options, see http://www.mathworks.com/support/compilers/R2015b/win64.html.

这里好像是因为下载的win sdk7.1是.net Framework4的,而win10的版本应该在.NET Framework 4.6,所以在这里出现一点问题。
这里写图片描述
具体参考:
https://cn.mathworks.com/matlabcentral/answers/279692-why-does-microsoft-windows-sdk-7-1-not-get-detected-as-a-supported-compiler-for-windows-10-with-fram

当下载完上述网站给的链接后,matlab应该可以正常mex了
http://www.microsoft.com/en-us/download/confirmation.aspx?id=4422

>> mex -setup
MEX 配置为使用 'Microsoft Windows SDK 7.1 (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

以上,欢迎大家继续补充

==============================================================
2017年3月6日更新================================================
有个好友也出现了这个问题,我也将其整理如下:
他的配置如下:MATLAB2016b VS2008 MinGW4.9.2 win7 64位
由于Matlab2016b并不支持VS2008,所以他已经下载好MinGW4.9.2
然而mex出现如下问题:
这里写图片描述

本人感觉应该是MinGW在windows下不能被Matlab识别,因此还是安装个SDK靠谱。
于是建议他安装SDK,链接如下:
https://www.microsoft.com/en-us/download/details.aspx?id=8279

于是便可以正常编译了,如下图:
这里写图片描述

以上
欢迎大家指正补充

注:
实际上如果没有Visual Studio的话,只要下载一个合适的SDK,matlab便能正常编译,没必要都按网上的版本进行特定安装,否则有了VS2015,又装一个VS2013实在蛋疼

                                </div>
            <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e44c3c0e64.css" rel="stylesheet">
                </div>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值