how to load my code c++ to raspberrypi

7 views (last 30 days)
fikana cantri
fikana cantri on 22 Jun 2019
Answered: Shaunak on 10 Jun 2025
I have generated my simulink model code into c ++, and produced many c++ files with the header. but I don't know how to bring it all to raspberry pi and run it. how do all the files generate code run on raspberry pi? what should I do after generate code and getting the c ++ file? does the folder just copy it to raspberry?
this is the contents file of the generated code
ss file code1.png
ss file code2.JPG

Answers (1)

Shaunak
Shaunak on 10 Jun 2025
It is my understanding that you have generated C++ code from your Simulink model and have a Raspberry Pi setup ready, and now you want to deploy and run the generated code on the Raspberry Pi.
Here’s how you can do it:
  • Copy the Generated Code to Raspberry Pi: Use scp or a USB to copy the entire code generation folder (including .cpp, .h, and Makefile if available) to your Raspberry Pi:
scp -r mySimulinkCode pi@<raspberry_ip>:~/simulink_build/
  • Compile the Code on Raspberry Pi: SSH into the Pi, go to the folder, and compile the cpp file using:
g++ *.cpp -o myModelApp
  • Run the Executable: After successful compilation, you can run the generated executable on your Raspberry Pi hardware.
For additional information on deploying generated code onto Raspberry Pi, kindly refer to the following MathWorks documentation:
Hope this helps!

Categories

Find more on Embedded Coder 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!