cancel
Showing results for 
Search instead for 
Did you mean: 

Building TouchGFX in Clion, compiler says multiple definition of functions in OSWrappers.cpp

VanSharkholme
Associate II

I'm trying to start a project using TouchGFX on stm32H743IIT6 and I generated the project with CubeMX, and when I try to build the project with Clion, there are errors about simulator source files.So I excluded all directories about simulators in cmakelists, and compiling seems to work but there are errors of multiple definition of functions, and after checking, I found that all these multiple definition errors are related to functions in OSWrappers.cpp and OSWrappers_cmsis.cpp. Then I tried to open project in CubeIDE and compile with it, and there are no errors this time, everything is fine. I also tried to generate the project in MDK-ARM form and build it in Keil, still no problem. It seems only Clion can't build the project properly and I'm wondering if there's a way to compile in Clion.

Here are the changes I made in Cmakelists:

file(GLOB_RECURSE excludes "Middlewares/ST/touchgfx/framework/source/platform/hal/simulator/*.*" "Middlewares/ST/touchgfx/framework/source/platform/driver/touch/SDL2TouchController.cpp" "TouchGFX/generated/simulator/*.*" "TouchGFX/simulator/*.*")
list(REMOVE_ITEM SOURCES ${excludes})

added after 

file(GLOB_RECURSE SOURCES "TouchGFX/*.*" "Core/*.*" "Middlewares/*.*" "Drivers/*.*")
7 REPLIES 7
GaetanGodart
ST Employee

Hello @VanSharkholme ,

 

I have seen a reddit post where someone is asking the same thing and he seemed to not have a lot of success.
Furthermore, TouchGFX is supported for:
 - Keil μVision (Target only)
 - IAR Embedded Workbench (Target only)
 - STM32CubeIDE (Target only)
 - Microsoft Visual Studio (Simulator only)

 

That being said, we have documentation about using IDEs : using-ides-with-touchgfx 

To use another IDE, you first need to use the correct compiler. Good for you, JetBrains also have documentation about that : how-to-switch-compilers-in-clion .
Basically, you need to set the same gcc as the one we are using.

After that you also need to use our Makefile. I saw that you mentioned a CMake file. TouchGFX do not use CMake, I cannot confirm the compatibility (or rather portability).

Then you also have to specify your cortex.

 

Overall, it seems like a quite complex and time consuming task.

If you can avoid it, I would recommend to.

Personally, I edit my code using VSCode and then I compile using whatever IDE I want based on the compiler I need.

Since you need GCC, I would recommend you to edit your code in CLion and then opening back your project in Designer and flashing from there.

 

I hope this helps, if the solves your problem, I invite you to select this comment as "best solution".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
EmbDev
Senior

My project also uses CMake (in combination with VS-Code).
First you need to verify whether your build setup is correctly configured.
Easiest way is to build an hello world application with some blinking LEDs.
Next step is to add TouchGFX to the project, in general I would recommend you to avoid glob.
You should not build both `OSWrappers.cpp` and `OSWrappers_cmsis.cpp`, check which one is used in the CubeIDE project.

Thanks for reply, after reading your suggestions, I tested My Clion build setup and it should be fine since I managed to build simple projects generated from CubeMX. After this, I excluded files in TouchGFX/target and OSWrappers_cmsis.cpp, and now the problem is undefined reference about some functions. Maybe it's because of the generated Cmakelists contains problems? Should I attempt to write my own Cmakelists?

Hello @GaetanGodart ,

 

I understand what you mean now, porting the make files does seem kinda tricky, so I'm gonna try working on this for a while and if it still doesn't work out in next few days, I'll just compile with some other IDEs.

 

Thanks

I do not have any experience with generated CMakeLists. In general ST only just started with some support for CMake, will take some time before it gets mature. If you have undefined references you have to add the missing files to the CMakeLists.

GaetanGodart
ST Employee

Hello @VanSharkholme ,

 

Have you been able to move forward regarding your question?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hello @VanSharkholme ,

 

Have a look at this post : community.st.com/t5/stm32-mcus-touchgfx-and-gui/how-to-set-up-touchgfx-for-stm32cubemx-generated-cmake-project/td-p/678889

Aquamarine explains how he was able to generate code and flash it by using VSCode.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)