How to use functions from the wiringPi library in an s-function? (missing -lwiringPi flag)

2 visualizaciones (últimos 30 días)
I'm trying to use functions from the wiringPi library for my RaspberryPi. I want to use these in a Simulink S-Function. I've found some guides for this and they say you need to add #include wiringPi.h to the Libraries panes in the s-function builder. I also add an #ifndef to make sure the functions are only used when I'm running the model on the target hardware (rpi):
#ifndef MATLAB_MEX_FILE
#include <wiringPi.h>
#endif
My problem is:
When I want to run the model in external mode or deploy it, I get an error message. Every wiringPi function I use results in an "unspecified reference" error. Some guides say that in order to fix this you need to use "xmakefilesetup", but it doesn't do anything for me. I'm using r2016a, so maybe xmakefilesetup is not functional anymore.
Other guides also mention that you should put all the wiringPi files in your MATLAB directory. This does not help me either.
It seems like the compiler has no problem finding the files I want to include. However, when compiling c code with wiringPi directly on the Raspberry, you always need to use the "-lwiringPi" flag on the gcc compiler. I think the fact that the s-function builder does not add this "-lwiringPi" flag to the compiler settings causes the error. Somewhere I read that you need to manually add this flag to the Simulink Makefile. How would you do this? Is there a way to add the flag manually?
If anyone knows how to use wiringPi functions in the s-function builder in r2016a, I would love to hear from you how to do it.
Thanks.

Respuestas (0)

Categorías

Más información sobre Embedded Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by