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

I am trying to include custom code in a Simulink® Real-Time™ (SLRT) model that depends on static or dynamic runtime libraries. Are Windows libraries (.dll, .lib) or Unix-style libraries (.so, .a) supported for deployment to Speedgoat® hardware? Which compiler toolchain must the custom library comply with for SLRT to compile and link it successfully?

 Accepted Answer

Custom libraries are generally supported with Simulink Real-Time (SLRT), as long as they are compiled with the same compiler toolchain used by SLRT. The requirements depend on the MATLAB release used:

For R2020b and newer:

Simulink Real-Time supports Unix-style dynamic shared libraries (.so) and static libraries (.a). Windows libraries (.dll, .lib) are not supported.
These .so and .a libraries must be compatible with the specific RTOS used by SLRT:
  • For R2026a and later, SLRT uses a 64-bit Linux-based RTOS. This requires compiling with the cross-compiler for your Linux-based RTOS target computer, which is provided by Speedgoat.
  • In R2020b through R2025b, SLRT uses the 64-bit POSIX-compliant QNX® Neutrino® RTOS. This requires compiling the libraries with the proprietary QNX C/C++ compiler (qcc), which must match the version bundled with the 'Simulink Real-Time Target Support Package' (qcc v7.0.0 in R2020b; qcc v7.1.0 in R2021a–R2025b). Refer to our open-source eCAL Toolbox for Simulink, where the buildeCALlibs4QNX.cmd script demonstrates how to configure the qcc compiler from our Support Package to cross-compile QNX libraries using CMake. 
To utilize shared dynamic libraries (.so), these must be transferred to the target filesystem before use. Static libraries (.a), on the other hand, are directly integrated into the real-time application file on the host.
For detailed guidance on integrating external code and libraries with SLRT, refer to the links below:
NOTE: When working with FMUs, you can leverage the built-in slrealtime.fmu.compileFMUSources cross-compilation function. See: How can I run my Simulink model containing an FMU on Speedgoat hardware with SLRT? 

For R2020a and Earlier:

Simulink Real-Time operates on the Win32 API-compatible 32-bit On-Time RTOS. Only static libraries (.lib) are supported. Windows dynamic libraries (.dll) and Unix-style libraries (.so, .a) are not supported.
To use these libraries on an SLRT 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.

Further information:

For more information on adding external libraries as build dependencies to the build process (custom code section), see:

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!