Matlab安装后需要支持的编译器

今天(2022-6-16)在Win10系统新装最新版 Matlab(R2022a),完全安装模式,占用空间大小31.2G,下载安装共耗时约2h。

安装完毕后提示:您的安装可能需要额外的配置步骤。

要加快以下产品的计算速度,需要支持的编译器

  • Fixed-Point Designer
  • SimBiology

以下产品需要支持的编译器:

  • Embedded Coder
  • MATLAB Coder
  • Simulink Coder

MATLAB Compiler 需要支持的编译器来创建 Excel 加载项。

MATLAB Compiler SDK 要求安装以下程序:

需求确认

分析一下,目前、或将来可能会需要:

  • 加快计算速度(Fixed-Point Designer)
  • Embedded Coder、MATLAB Coder、Simulink Coder
  • 创建 COM 组件、C 和 C++ 共享库

上述提示中的链接最终指向两个目标:

  1. Supported and Compatible Compilers
  2. Interfaces to Other Languages

从中寻找需要的编译器和辅助程序。

第三方编译器 MinGW

A number of MathWorks products or product features require that you have a third-party compiler installed on your system. The tables below outline the compilers that are supported by various MathWorks products. These compilers are provided by a number of vendors and are available under a variety of commercial, academic, or open source terms; visit the providers' websites for further information.

Matlab Compiler

显然,MATLAB Product Family 是推荐选用 MinGW 6.3 C/C++ 的;

MinGW 6.3 C/C++ 对 Simulink Product Family 的支持极其全面:

  • Simulink: For S-Function compilation
  • Simulink: For Model Referencing, Accelerator mode, Rapid Accelerator mode, and MATLAB Function blocks
  • Stateflow: For all features
  • Simulink Coder: For all features
  • Embedded Coder: When targeting the host OS
  • SerDes Toolbox: For IBIS-AMI model generation

MinGW 6.3 C/C++ 对 MATLAB Compiler 的支持:

  • MATLAB Compiler: Excel add-in for desktop
  • MATLAB Compiler SDK: C/C++
  • MATLAB Compiler SDK: COM

不支持MATLAB Compiler SDK: .NET(需要 Microsoft Visual C++)

MinGW 6.3 C/C++ 的下载链接引导到:MATLAB Support for MinGW-w64 C/C++ Compiler

MinGW-w64 is a compiler suite for Windows based on the GNU tool chain. It includes a GCC compiler and related tools for compiling C and C++ applications for Windows. C and C++ applications compiled with MinGW-w64 GCC can be called from MATLAB using MEX. This GCC compiler can also be helpful for other MathWorks products that require a C or C++ compiler.

真正下载链接:download Select the download button, above, then double click on the file or drag it into the MATLAB Command Window to install.

一个16KB的文件mingw.mlpkginstall,双击(Win10系统已经注册过该类文件为MATLAB Support Package Installer),打开Matlab的附加功能管理器,安装。

需登录Matlab账号验证,以在线下载所需资源。

1
2
3
MATLAB Support for MinGW-w64 C/C++ Compiler 版本  22.1.0
第三方软件:
MinGW 6.3.0 from MinGW-w64.org

This Add-On installs one of the following versions of MinGW GCC based on your version of MATLAB:

MATLAB version MinGW version For more information
R2018b and later GCC 6.3 http://mingw-w64.org

完毕,命令行验证 OK。

1
2
3
4
5
6
>> mex -setup
MEX 配置为使用 'MinGW64 Compiler (C)' 以进行 C 语言编译。

要选择不同的语言,请从以下选项中选择一种命令:
mex -setup C++
mex -setup FORTRAN

Interfaces to Other Languages

其他语言接口。

MATLAB®, MATLAB Production Server, and its add-on products are compatible with the following versions of other programming languages. For information about which versions of Python are compatible with previous releases of MATLAB, see Versions of Python Compatible With MATLAB Products by Release. For more information, see Using MATLAB with Other Languages.

与其他编程语言结合,包含三种途径:一是从其他语言调用 Matlab (Engine API);二是从 Matlab 调用其他语言(编写的库)或system components;三是通过 MATLAB Compiler and MATLAB Compiler SDK 打包成其他语言的组件。

支持语言包括:

  • C - All versions prior to 11
  • C - Version 11 (不支持从Matlab调用)
  • C++ - All versions prior to 11
  • C++ - Version 11
  • C++ - Version 14
  • Fortran - All versions
  • Python 2.7 | 3.7 | 3.8 | 3.9
  • .COM components and apps - all versions
  • Java 8 (Oracle Java)
  • Java 8 (OpenJDK) (不支持从Matlab调用)
  • .NET Framework CLR version 2.0 | 4.0 (不支持调用Matlab)
  • HTTP 1.1 (不支持调用Matlab)
  • Perl 5.32.1(不支持调用Matlab)

此外,Matlab Coder | Embedded Coder | Simulink Coder 支持将 Matlab | Simulink 转换为其他语言代码。