Showing results for 
Search instead for 
Did you mean: 

How to add additional header and source files to TouchGFX project

Associate II

So I've been messing with TouchGFX for a while now using the designer to construct the various GUI portions on my application. However I am now at a point that I need to add additional C++ classes to my project and I am having a hard time figuring out how to make them part of the TouchGFX project.

I have a STM32CubeIDE project named "Project" inside of which I have the "TouchGFX" folder that was generated when I configured the project for my target. I can successfully build and run my TouchGFX application on the target. Additionally I can also run the application using the simulator with out any issues.

I have added a new folder inside the "TouchGFX" folder called "additional" that contains a "src" and "include" folder for header and source files that I need to be included in the project (note the "src" and "include" folders also have sub folders in the to organize my files).

How can I make this "additional" folder and all its contents part of the project so they are compiled when I build the project for the target or the simulator and they show up correctly in the Visual Studio Solution Project?

If any one could help it would be much appreciated as I can't continue making progress on my application till this issue is resolved.

!!!!!!!!!!!!!!!!!EDIT UPDATE!!!!!!!!!!!!!!!!!

I have edited the ADDITIONAL_SOURCES and ADDITIONAL_INCLUDE_PATHS variables in the TouchGFX\simulator\gcc\Makefile... to read as follows but it still does not work... not sure what I'm doing wrong here...

temp_test_additional_path := ${application_path}/additional/src/

ADDITIONAL_SOURCES := $(call find, $(temp_test_additional_path),*.cpp)

ADDITIONAL_INCLUDE_PATHS := ${application_path}/additional/include/

!!!!!!!!!!!!!!!!!EDIT UPDATE!!!!!!!!!!!!!!!!!


Jagdish Bisawa
Associate III

Hello @JustAnotherGuy​ ,

If you look into the folder gcc, you will find the Makefile that is used for building the project. Look for the section where the c, c++ & h files to be included are defined. For e.g. search for "board_c_files".

Here you can either add to the existing list, your c/c++ files to be compiled or you can define your own variable & then list it to be compiled. If you've worked on open source compilers before then understanding this Makefile should be relatively easy ( there is no need to understand it fully, any ways. However, for academic purpose it makes sense to understand it. ).

Hope the above helps.

\Jagdish Bisawa

This does not appear to be how TouchGFX's make files are laid out.... None of the make files in the TouchGFX folder (of which there are two) appear to have the "board_c_files"

I suspect I would need to add something to either the:



I have messed around with them a bit trying different things but I am still not sure what or how to add the "additional" folder and all its header and source files... nothing I have tried works


Jagdish Bisawa
Associate III

Hi @JustAnotherGuy​ ,

I had an impression that you were using a hardware such as the discovery board etc. & hence suggested to add to the Makefile under the gcc folder.

It seems you are using the simulator ( i.e. PC as the target ). In that case try making changes to the Makefile under TouchGFX\generated\simulator\gcc\Makefile, as understood by you correctly.

Look for the definition of include_paths source_paths. You may add your path to these variables & try.

/Jagdish Bisawa

My question relates to the both the target hardware and the simulator, see my edit above in my original post... Still don't have this working and I'm very disappointed that what is a trivial task in any other development environment is such a pain in the context of TouchGFX.​ I have not been y terribly impressed with the TouchGFX documentation either.

Jagdish Bisawa
Associate III

Hi @JustAnotherGuy​ ,

I have tried both - adding additional file names to the Makefile for a discovery board project & to the Makefile for a PC simulator project. In both cases it has worked for me. The only difference being that I use command line to make the project & you are making use of VS.

Add your additional 'include' folder name to the include_paths variable & additional 'src' folder name to the source_paths variable, in the Makefile found under TouchGFX\generated\simulator\gcc\.

There is no need to make any changes to the Makefile found in TouchGFX\simulator\gcc\.

/Jagdish Bisawa

Senior III

Aren't the make files regenerated by TouchGFX? I tried modifying the make files but my changes keep being overwritten. I need a solution that allow include additional paths and files permanently to the project.

I develop the application using STM32CubeIDE for building the project for the target. It has it's own configuration for include directories and files. The problem is when I add a path there, it is not added to the TouchGFX Designer.

A good workaround would be just adding them somehow to the TouchGFX Designer configuration manually, but not having to fight with the tool overwriting my changes.