Skip to main content
AG.6
Associate
May 10, 2021
Question

Converting main.c to .cpp in generated TouchGFX project caused errors

  • May 10, 2021
  • 5 replies
  • 2353 views

Hi, I am quite new here so sorry for this simple question.

I have STM32 F746G discovery board and I generated project through TouchGFX designer and imported it to Cube IDE, but it generated main.c file.

The project is C++ project, but when I try to rename main.c to main.cpp it will generate errors during compilation. I have no idea why I am getting these errors. Thanks in advance!

I have no idea why it is working with .c and not with .cpp

undefined reference to MX_TouchGFX_Init()

undefined reference to MX_TouchGFX_Process()

0693W00000ANvI3QAL.png

This topic has been closed for replies.

5 replies

Romain DIELEMAN
ST Employee
May 11, 2021

Hi,

The main is supposed to be in .c as it is used by STM32CubeMX. It is TouchGFX that uses C++. It is usually never a good idea to modify the format of a file :grinning_face_with_sweat:. Could you explain how you imported the project to STM32CubeIDE ?

/Romain

AG.6
AG.6Author
Associate
May 11, 2021

Thank you for reply.

I simply opened TouchGFX designer application where I selected my discovery board (STM32 F746G discovery) and blank screen, then clicked generate to generate TouchGFX files along with multiple IDE project files (cube IDE project included).

In CubeIDE I clicked

File -> Open Projects from File System

and selected whole generated directory with CubeIDE project and TouchGFX

I was trying to import it by clicking on generated .project file, but it is pretty much same result

It is important for me to have main in cpp. How could I do it?

If you have some time and will, you could create blank UI touchGFX project for 746G discovery with main.cpp for me? That would be awesome.

Romain DIELEMAN
ST Employee
May 11, 2021

Instead of using the "Open Projects from File System" option you can just double click on the generated .cproject or .project under the /STM32CubeIDE folder. To convert to cpp you just need to right click on main.c in the tree view in STM32CubeIDE and check the "Update References" option.

According to this post you shouldnt do it in a file explorer. Why it is important to have it in cpp ?

AG.6
AG.6Author
Associate
May 11, 2021

Thank you!

Although it only appears to be main.cpp, when I try to use some c++ features it is not working. There is still main.c in Core/Src

0693W00000AO1xqQAD.png

Romain DIELEMAN
ST Employee
May 12, 2021

I would advise to edit the Topic section of your post to add the relevant tags to increase your question's visibility. This is not a TouchGFX issue so I do not know where to further guide you sorry :downcast_face_with_sweat:

/Romain