Install Simulink Support Package for Rust Code
The Simulink® Support Package for Rust® Code enables integration between Simulink models and applications based on Rust. Rust is a programming language designed for performance and memory safety. This support package allows you to combine Model-Based Design workflows using Simulink with the Rust programming environment.
Installing the Simulink Support Package for Rust Code includes installing MATLAB®, Simulink, and other related tools relevant to Rust programming environment.
Prerequisite
Before using the Simulink Support Package for Rust Code, you must have these tools installed:
Rust compiler
Clang compiler
You can download the Rust compiler from https://www.rust-lang.org/tools/install.
After installation, you can verify that Rust compiler is available in your system path by running this command.
rustc --versionTo install the Clang compiler on Windows®, install MSYS2 and use the pacman package manager:
Download and install MSYS2 from the MSYS2 website.
Open the MSYS2 MinGW x64 terminal.
Install Clang.
For Windows, use this command.
pacman -S mingw-w64-clang-x86_64-clangFor Linux®, use this command.
sudo apt install clang
These commands install the 64-bit Clang compiler for the MinGW-w64
environment. The compiler is used to build and link C source files generated from
Simulink models with Rust code.
After installation, you can verify that Clang is available in your system path by running this command.
clang --versionInstall and Manage Support Package
You can add support for Rust language in Simulink. When you complete the installation process:
You can import external C compatible Rust code into Simulink.
You can use command-line APIs to generate Rust bindings for C code generated from Simulink models. The bindings provide Foreign Function Interface (FFI) access to model functions and data.
Install Support Package
You can find and install this support package using the Add-Ons panel. To open the Add-Ons panel, click the Add-Ons
icon on the left sidebar of the desktop. If the
Add-Ons icon is not on the sidebar, click the Open more panels
button and select
Add-Ons.Use the search box to search for Simulink Support Package for Rust Code.
To install the support package, select it from the search results and click the Install button.
You can also use the Add-On Explorer to browse through the full list of available add-ons. To open the Add-On Explorer from the Add-Ons panel, click the Browse link at the bottom of the Recommended for You section. Alternatively, go to the Home tab, and in the Environment section, click the Add-Ons icon. The Add-On Explorer opens and displays the list of available add-ons.
Find Add-On — Use the search box to search for Simulink Support Package for Rust Code, or browse through the available categories on the left side of the Add-On Explorer window. Select Simulink Support Package for Rust Code in the list to view additional information about it, such as what files it includes and what documentation is available.
Install Add-On — Select the support package from the search results or the list of support packages. Then, select from the available installation actions. After you install an add-on, MATLAB manages the MATLAB path for you, so, you can start using the add-on without adjusting your desktop environment.
Manage Support Package
You can view and manage the support package using the Add-Ons panel. To open the
Add-Ons panel, click the Add-Ons
icon on the left sidebar of the desktop. If the Add-Ons
icon is not on the sidebar, click the Open more panels
button and select the Add-Ons panel. The Add-Ons panel
displays the installed support package.
To manage your support package, in the Installed section of the Add-Ons panel, click the Options button to the right of the add-on that you want to manage. Alternatively, to manage the support package using the Add-On Manager, click the Manage link at the bottom of the Installed section.
Once you access the options to manage the support package, you:
Disable support package — To disable the support package, click the Options button and clear the Enabled check box. To reenable the support package add-on, select the Enabled check box. If an add-on has multiple versions installed, only one version can be enabled at a time. You also can disable and reenable add-ons using the
matlab.addons.disableAddonandmatlab.addons.enableAddonfunctions, respectively.Uninstall support package — To uninstall the support package , click the Options button and click Uninstall.
View support package version — To view the currently enabled version of the support package if it has multiple versions installed, click the Options button and select Version. MATLAB displays a check mark next to the currently enabled version. To enable a different version, click it. For more information about installing multiple versions of an add-on, see
matlab.addons.install.Update support package — To update the installed support package, click the Update button to the right of the add-on. The Add-Ons panel displays the Update button next to add-ons with available updates.
To check whether any installed add-ons or your current installed version of MATLAB has an update available, go to the Home tab and select Help > Check for Updates. The Add-Ons panel shows any available updates.
Run the Support Package
Using the support package, you can:
Create Rust bindings for C code generated from Simulink models. For more information, see Generate Rust Bindings for Simulink Generated C Code (Embedded Coder).
Import external Rust code into Simulink. For more information, see Import C Compatible Rust Code into Simulink Using the Rust Importer Wizard.