How can I link to a library in a Simulink s-function for RaspberryPI as target system?

1 view (last 30 days)
Hello, I am trying to access a MySQL database from Simulink running on a RaspberryPI as target Hardware. My approach is to write an S-Function containing the C code to do the database operation.
The C code itself depends on "libmysqlclient-dev" and can be compiled successfully on the PI directly by linking to "-lmysqlclient".
But when I insert the code in the s-function, I don’t know where to add the linking argument.
I so far tried to place the argument at various places in the configuration of the s-function and the C/C++ code generation and always received the error message that there is a undefined reference to the MySQL functions or that the library could not be found.
When I opened the Makefile that is generated each time the code is prepared to be run on the PI there were several linking arguments like "-pthread" but the "-lmysqlclient" never appeared.
Now my question is, where and how can I do the linking to the library?
Are there more elegant ways to access the database?
Thanks in advance
//example code to demonstrate the problem
#include <stdio.h>
#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char **argv)
{
printf("MySQL client version: %s\n", mysql_get_client_info());
exit(0);
}

Answers (1)

Sotos Thanopoulos
Sotos Thanopoulos on 9 Aug 2016
Hej ANK,
you have any progress to your question, I am trying to do the same but I haven't find a way.
Thanks in advance, Sotos

Categories

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