Clear Filters
Clear Filters

Can I use custom libraries (.dll/.lib/.so/.a) with Simulink Real-Time?

18 views (last 30 days)
Are custom Windows libraries (.dll/.lib) or Unix libraries (.so/.a) supported for integration with my real-time model running on Speedgoat hardware when using Simulink Real-Time (SLRT)?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Jul 2024 at 0:00
Edited: MathWorks Support Team on 4 Jul 2024 at 22:11
Custom libraries are generally supported with Simulink Real-Time (SLRT), as long as they are compiled with the same compiler used by Simulink Real-Time. The specific details depend on the MATLAB release you are using:
 

For R2020b and Newer:

Simulink Real-Time has adopted the QNX Neutrino 64-bit Real-Time Operating System (RTOS) and supports both dynamic (.so) and static libraries (.a). Windows libraries (.dll/.lib) are not supported in these versions.
These .so and .a libraries must be compiled with the QNX C/C++ compiler (qcc) compiler matching the version included in the Simulink Real-Time Target Support Package. To utilize shared dynamic libraries (.so), these must be transferred to the target's filesystem before use. Static libraries (.a), on the other hand, are directly integrated into the real-time application file on the host.
For a detailed guide on integrating external code and libraries, refer to the link below. The "Additional C/C++ Project for Simulink Real-Time" section at the bottom of the page has a reference to a full example hosted on GitHub:
Additionally, you can learn how to compile source code into a library using the QNX compiler (QCC) within the context of FMUs from this documentation:
 

For R2020a and Earlier:

Simulink Real-Time operates on a Win32 API-compatible 32-bit RTOS. Only static libraries (.lib) are supported. Windows dynamic libraries (.dll) and Unix libraries (.so/.a) are not supported.
To use these libraries with your S-Function on a Speedgoat target, they must be compiled as 32-bit libraries using Visual Studio. Ensure you have both 32-bit (for the target) and 64-bit (for the host) versions of your libraries. You can then use the "rtwmakecfg.m" method to add the libraries to the build process.
For more information on customizing generated makefiles and adding build dependencies, see:

More Answers (0)

Categories

Find more on Troubleshooting in Simulink Real-Time in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!