How to compile, using GNU GCC Raspberry Pi Simulink compiler, S-functions that need external libraries (.lib)?

조회 수: 5 (최근 30일)
I am trying to compile and deploy from my Win7 64bit laptop to a Raspberry Pi 3 Model B a Simulink Phase Space model having inside a Sfunction to include in the model a c++ code that my university provided me. I am sure to be connected to the Pi (I get the mypi variable and establish the connection), indeed I am able to compile and deploy to the Pi simple Simulink models (for instance to blink the Pi's green led).
The issue is when I try to compile the full Phase Space model because the c++ function needs some external libraries (.lib) to run. I am able to compile the .mexw64 file from Matlab using SDK compiler and providing it with the libraries. But when I compile and deploy the full Phase Space model from Simulink (''Deploy to hardware'' button) using the GNU GCC Raspberry Pi compiler I get an error saying the .lib extension is not recognized. So my question is how to compile Sfunction requiring external libraries .lib?
Thanks, cheers

답변 (2개)

Shivang Menon
Shivang Menon 2017년 1월 23일
Are you able to simulate the model? To compile the S-function, you can use the mex function - https://www.mathworks.com/help/matlab/ref/mex.html#btx0rai-1 . So, something like
>> mex s_function.c other_c_files.c -lLibraryFolderPath -lLibraryName
This would create a .mexw64 file.
In order to include the library in the generated code, you need to add the library path and library files in the custom code section of code generation pane of configuration parameters. Refer to the following link:
  댓글 수: 2
Simone Rafano Carna
Simone Rafano Carna 2017년 1월 23일
편집: Simone Rafano Carna 2017년 1월 23일
Hi Shivang, thanks for the answer. Yes I am able to simulate, I am not able to deploy to the hardware (Raspberry Pi Model 3).
As I wrote: I am able to compile the .mexw64 file from Matlab using SDK compiler and providing it with the libraries. (i.e. I already use the mex function you suggest and it works).
The issue is when I deploy to the hardware the full Simulink Phase Space model... I ve also put that library in the custom code section of code generation pane of configuration parameters. Still doesn't work.
Thank you again Simone

댓글을 달려면 로그인하십시오.


Marian Kersting
Marian Kersting 2018년 3월 27일
Did you install the "Raspberry Pi Hardware SupportPackage"? Does it work with this one? It deploys also al full Toolchain with GCC compiler. Somewhere over here... https://de.mathworks.com/hardware-support/raspberry-pi-matlab.html
  댓글 수: 1
Rodrigo Estrella
Rodrigo Estrella 2019년 1월 8일
I have the same problem but with source files cpp and hpp. I can simulate, i have installed the support package. The problem i have is that the source files are all copied in to the same ert_rtw directory in the raspberry pi, not respecting the original directory structure. Then when compiling the header files are not found (the includes in the files don't correspond to the files location in the raspberry pi)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Run on Target Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by