Showing results for 
Search instead for 
Did you mean: 

Touch GFX Simulator does not understand external variables from project.

Associate III

hello everyone I create a project in Touch GFX, generate code, make my changes to the xxx.ioc file,
open it in Cube IDE with xxx.cproject . I compile, create my variable in the <usbd_cdc_if.c> file, use it in <Screen1View.cpp> how extern variable , run it,
everything works fine in reality STM32F429I-DISC1 board, but when I try to Touch GFX simulate it. it gives an error
about the my <Screen1View.cpp> extern variable .

.... \TouchGFX/gui/src/screen1_screen/Screen1View.cpp:72: undefined reference to `my_char_Rx_buf'

after that I read that I should add in the file <Model.cpp>

extern "C"
#include "main.h"    //////// or another .h file for example    usbd_cdc_if.h

but I noticed that in CubeIDE it seems that all <zzz.h> files are ignored, for example, the compiler does not react
to changes made in the file <main.h> ; <usbd_cdc_if.h>

how can understand this ???

thank you in advance


Hello @gevmar ,
If you want your code to be recognized by the TouchGFX simulator, you should place your code under the gui directory (you can create folders under gui/src or gui/Inc). Then, you can easily access it through your application. Otherwise, you should place it in the extern block or between #ifndef SIMULATOR #endif
For instance, you can take a look at one of the Board Specific Demos available in the TouchGFX designer, in the Demos section.

For your second issue, the header files should be under the Includes section and then you will see a list of all the include directories that are specified in your project settings. So if you don't see the list, please check that the include paths are defined in your project properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC and MCU G++   -> Include Paths


Include PathsInclude Paths


I hope this helps you, don't hesitate to ask more questions

Mohammad MORADI
ST Software Developer | TouchGFX