Why do I get errors about missing "slhostlibcan***.dll" files when running a generated executable using CAN functionality outside MATLAB?

조회 수: 13 (최근 30일)
I've designed a Simulink model that transmits CAN data using blocks such as "CAN Transmit", "CAN Receive" or "CAN Replay" block from the Vehicle Network Toolbox. I generated an executable from this model using Simulink Coder or Embedded Coder. Upon running the EXE file, I get the following errors in the console
Could not open library: slhostlibcantransmit.dll.Could not open library: slhostlibcanreceive.dll.Could not open library: slhostlibcanreplay.dll.
To run the generated code outside the MATLAB environment, use the packNGo function.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 7월 30일
편집: MathWorks Support Team 2025년 7월 30일

What This Issue Means

The errors you are encountering indicate that the Windows Desktop executable generated from your Simulink model cannot find the required DLL files "slhostlibcantransmit.dll","slhostlibcanreceive.dll", "slhostlibcanreplay.dll", or their dependencies, which are necessary for CAN blocks from the Vehicle Network Toolbox to function outside the MATLAB environment.
Refer to the "Code Generation" section in the CAN block documentation for details:
 

Try This Solution

To resolve these errors, use the "packNGo" function. This function bundles these necessary DLLs into a ZIP file for easy relocation of your project in a different Windows Desktop environment:
Once all DLLs from the packNGo archive are present in the same folder as the EXE file, you should be able to run the generated executable successfully.
Important note: Vehicle Network Toolbox's CAN blocks are for Desktop use on the same platform only. For CAN communication on embedded hardware or other platforms, the "packNgo" solution is not applicable.
For embedded hardware, replace the CAN blocks in your model with the appropriate ones from target-specific toolboxes and hardware support packages (e.g., Simulink Real-Time/Speedgoat, Raspberry Pi, Arduino, STM32, TI C2000). Browse our documentation for various 'CAN Transmit' and 'CAN Receive' blocks:
For Linux desktop platform, install MATLAB on that platform to obtain the correct shared libraries (.so files).

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by