Can I use custom libraries (.dll/.lib/.so/.a) with Simulink Real-Time?
11 views (last 30 days)
Custom libraries (.lib/.so/.a) are supported with Simulink Real-Time as long as they have been compiled with the same compiler that Simulink Real-Time uses. Depending on the MATLAB release that you are using, please note the following:
In R2020b and later, Simulink Real-Time uses the QNX 64-bit RTOS and supports dynamic (.so) and static libraries (.a). In both cases, the library must be compiled with the QNX C/C++ (qcc) compiler matching the version included in the Simulink Real-Time Target Support Package. Shared objects must be copied to the filesystem in the target before being able to use them, whereas static libraries are directly added to the real-time application file on the host.
The following tutorial is a great resource to get started:
External Code Integration of Libraries and C/C++ Code with Simulink Real-Time Models - MATLAB & Simulink (mathworks.com)
In R2020a and earlier, Simulink Real-Time uses the Win32 API compatible 32-bit RTOS. Only static libraries (.lib) are supported. in order to compile static libraries to link against your S-Function and run it on your Speedgoat target, they must be compiled as 32-bit libraries using Visual Studio. Please note that dynamic libraries (.dll) are not supported.
Once you have both 32-bit (for target) and 64-bit (for host) versions of your libraries, you can use the rtwmakecfg.m method to add the libraries to the build process: