2023-11-28 06:03 AM
please help someone if you can. The program in CubeIDE compiles and Run without errors , but TouchGFX Simulator not recognize variable exported from another xxx.c file ( usbd_cdc_if.c ; uint8_t my_char_Rx_buf ; ) . In Screen1View.cpp file ( extern uint8_t my_char_Rx_buf ; ) .
In TouchGFX
.......Screen1View.cpp:72: undefined reference to `my_char_Rx_buf ...
collect2.exe: error: ld returned 1 exit status
generated/simulator/gcc/Makefile:160: recipe for target 'build/bin/simulator.exe' failed
2023-12-08 02:41 AM
Hello @gevmar
1.
It looks like a make file error according to the error message. This could be because you are trying to use C code in C++ program.
Where do you include usbd_cdc_if.c?
You probably have to include the header as external c.
Example:
extern "C"
{
#include "My_C_Header.h"
}
For your case, it would probably look something like that :
extern "C"
{
#include " usbd_cdc_if.h"
}
2.
If this step is done and the error persists, try making use of the Model-View-Presenter Design Pattern used by TouchGFX.
Here is the documentation about the MVP Design Pattern : MVP design pattern
Here is the tutorial using the MVP Design Pattern : MVP tutorial
3.
Sharing your project could help us understand the issue.
Hope this helps.
Don’t hesitate to give us a feedback or give more precisions.