问题
当使用Matlab的loadlibrary加载外部库时,可能会提示没有支持的编译器No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler; see Install MinGW-w64 Compiler.
解决问题
1、下载编译器安装文件
根据报错提示,首先从System Requirements and Supported Compilers查找不同Matlab版本支持的编译器,我是Matlab R2015b,查找到其支持的编译器可以从MATLAB Support for MinGW-w64 C/C++ Compiler下载。
2、安装编译器
- 根据评论区的提示,建议将下载的安装文件放在磁盘根目录下,
之后将该安装文件托到Matlab命令行窗口中运行,但是我出现了无法托进命令行的情况,此时也可以在Matlab中输入如下命令以启动安装
uiopen('C:\mingw.mlpkginstall',1)
- 启动之后需要登录Matlab帐号才能进行下载,如果没有帐号可以注册一个,Matlab账号并不需要license。
- 之后在下载时可能会报错:
Download Error: Received fatal alert: protocol_version
- 此时,可参考Installation of some MATLAB Support Packages fails with “Download Error” message (1741173)解决该问题。
- 之后重启Matlab即可正常下载和安装编译器。