- Open your model in Simulink.
- Go to the ‘Model Configuration Parameters’ by clicking on ‘Model Settings’ in the ‘Modeling’ tab or by pressing Ctrl+E.
- Navigate to the ‘Simulation Target’ section.
- Select the ‘Code Information’ tab.
- In the ‘Code Information’ tab, there are fields for inserting custom code snippets, such as ‘Include directories,’ ‘Source files’, ‘Libraries’, etc.
- In the ‘Linker flags’ field, add ‘-lpthread’. This will ensure that ‘-lpthread’ is added at the end of the link command.
Simulink coder link order
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to use the Simulink Embedded coder to build the blinking LED app on a Raspberry PI. Everything works except the link fails at the end because it cannot resolve the pthread functions. The generated link command is:
gcc -lrt -lpthread -ldl -o ../test.elf devices.c.o LED.c.o test.c.o test_data.c.o MW_raspi_init.c.o MW_Pyserver_control.c.o linuxinitialize.c.o ert_main.c.o -lm -lm -lstdc++
But it should be:
gcc -lrt -lpthread -ldl -o ../test.elf devices.c.o LED.c.o test.c.o test_data.c.o MW_raspi_init.c.o MW_Pyserver_control.c.o linuxinitialize.c.o ert_main.c.o -lm -lm -lstdc++ -lpthread
With the -lpthread being after the list of .o files. If I execute the second command by hand, the link succeeds and the test runs as expected.
Question: How can I fix that, or how can I add -lpthread after the .o files? I am using Matlab 2022 on a MAC and could not find any way of doing it in the Model Configuration Parameters menu.
Thanks
0 Commenti
Risposte (1)
Sachin Lodhi
il 19 Dic 2023
Hi Pascal,
It seems that the linking is failing because the ‘-lpthread’ flag is missing after ‘.o’ files. To resolve this and add ‘-lpthread’ after the object files, you can try the following steps:
Alternatively, you can consider the method outlined in the following MATLAB Answer: https://www.mathworks.com/matlabcentral/answers/109672-how-can-i-add-additional-linker-flags-to-the-generated-makefile
I hope this helps.
Best Regards,
Sachin
0 Commenti
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!