Skip to main content
Associate II
December 20, 2025
Solved

Create a new stm32 project correctly on 2.0.0 and use C++ for it

  • December 20, 2025
  • 1 reply
  • 817 views

Upgraded STM32CubeIDE to 2.0.0 and struggling with issues!
Installed CubeMX as a standalone program too. 

Now I'm confused how to create a STM32 project and as usual select C++ as the target language. 

1- Should I start from the IDE? There'll be no .ioc file then!
2- Should I start from CudeMX? There'll be no option to select C++ as the target language! 

How to fix it?
My purpose is to keep main.c, create .hpp, .cpp files and include the header in main.c to be able to call the functions defined in the .cpp file.

Best answer by TDK

Create the project in STM32CubeMX.

After you open it in STM32CubeIDE, right click the project and select "Convert to C++". This will add the C++ compiler and look for *.cpp files.

Then add whatever *.cpp files you want and it'll work. You'll need to extern "C" the ones you call in main.c so the names don't get mangled.

1 reply

TDK
TDKBest answer
Super User
December 20, 2025

Create the project in STM32CubeMX.

After you open it in STM32CubeIDE, right click the project and select "Convert to C++". This will add the C++ compiler and look for *.cpp files.

Then add whatever *.cpp files you want and it'll work. You'll need to extern "C" the ones you call in main.c so the names don't get mangled.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Explorer
March 8, 2026

Will CubeMX overwrite the project and convert it back to C if I regenerate code with it after editing peripheral settings? How do we deal with this?

Pavel A.
Super User
March 9, 2026

Hopefully ST will ensure that the next CubeMX update preserves the C/C++ project nature for CubeIDE.

@STTwo-32