Why do I get 'undefined reference to "c-method" ' error when trying to load my matlab function to arduino uno?
2 次查看(过去 30 天)
显示 更早的评论
Hi, I have a Simulink model containing a matlab function block. In this function two methods from my .c file are called, hc595_Init and hc595_SendData. These should set the selected pins as outputs and set them to low/high. When I try to download the simulink model to my arduino Uno I get the following error:
Error(s) encountered while building "Fan": ### Failed to generate all binary outputs
In the code generation report it says:
C:\Program Files\MATLAB\R2017b\Fan_ert_rtw/Fan.c:61: undefined reference to `hc595_Init' C:\Program Files\MATLAB\R2017b\Fan_ert_rtw/Fan.c:134: undefined reference to `hc595_SendData' collect2.exe: error: ld returned 1 exit status gmake: * [../Fan.elf] Error 1 C:\Program Files\MATLAB\R2017b\Fan_ert_rtw>echo The make command returned an error of 2 The make command returned an error of 2 C:\Program Files\MATLAB\R2017b\Fan_ert_rtw>An_error_occurred_during_the_call_to_make Der Befehl "An_error_occurred_during_the_call_to_make" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
Can anybody tell me why this error occurs?
Thanks!
采纳的回答
Shashank
2018-2-13
You need to add the your .c and .h files in the Simulation Target pane of the Configuration parameters of the model. Here is the exact procedure you need to follow:
Hope this helps.
- Shashank
2 个评论
Noam Greenboim
2020-10-21
If you generate C code from the simulink model, be sure to check "Use the same custom code settings as Simulation Target" under Code generation --> Custom code (in Configuration Parameters window).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 I2C Devices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!