Skip to main content
Visitor
July 21, 2026
Question

how to generate cpp project from stm32cube Mx

  • July 21, 2026
  • 2 replies
  • 23 views

after selecting the pins from cube MX, it will generate code in c but i want that in cpp

2 replies

ST Technical Moderator
July 21, 2026

Hello ​@siva_28 

STM32CubeMX mainly generates C code, but you can still use it very easily in a C++ project by generating the hardware initialization code with CubeMX, keeping those generated files unchanged as much as possible, and then adding your own .cpp and .hpp files for the application logic.

BR, Souhaib

To give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Ghofrane GSOURI
ST Technical Moderator
July 21, 2026

Hello ​@siva_28 

First make sure STM32CubeIDE is selected as the toolchain

 

After generating the code with STM32CubeMX , then open the project in STM32CubeIDE, right-click the project, and choose Convert to C++.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.