使用simulink选择grt.tlc生成C++代码时报以下问题
The specified code generation target is configured to generate C++, but the C-only compiler, LCC, is the default compiler. To allow code generation, you can select any C++ compiler from the Toolchain pulldown as well as selecting the 'Generate code only' option. To generate C code, open the Configuration Parameters dialog and set the target language to C. Or, to specify a C++ compiler, enter 'mex -setup' at the command prompt. For details on supported C++ compiler versions, seeSupport - System Requirements and Supported Compilers Previous Releases - MATLAB & Simulink
按照错误提示在matlab命令栏中运行mex -setup ,结果报以下错误
错误使用 mex
未找到支持的编译器或 SDK。您可以安装免费提供的 MinGW-w64 C/C++ 编译器;请参阅安装 MinGW-w64 编译器。有关更多选项,请访问
http://www.mathworks.com/support/compilers/R2016b/win64.html。
按照网上的说法,我这个是属于没有安装VS的类型问题,于是我按照官网和其他博客的指导,下载了对于的默认编译器(本人是2016B版本)
点击下载了相关的配置文件
但是一直显示在安装支持包,无论是在线还是离线时,都无法完成安装
最后根据官网下载路径下评论的这位老哥指出的方法,跟踪到知乎大佬给出的贴子
matlab 2019b安装gcc 6.3.0 编译器 - 知乎 (zhihu.com)
最后一通鼓捣,安装成功
这里需要注意:
设置环境这里,setenv的命令,路径需要放到下载的配置文件的路径下,且为当前的打开路径,不可教条主义呀,,,(我这里上面就是直接复制出错了)
好在最后还是安装成功了,记录一下完整过程吧(按照网上的说法,还有修改环境变量的,重新安装软件的,重新更新VC++的运行库的,我都试了一遍,全都没用,也许可能是问题本身不一致,也许可能就是无效的方法,不过小小问题硬控了我俩小时,实在伤脑筋。。。)