Skip to main content
Seenu
Associate II
August 8, 2022
Solved

How to integrate CPP code into STM32CubeIDE C project?

  • August 8, 2022
  • 3 replies
  • 11259 views

I have STM32CubeIDE C project already running for an application.

I am planning to integrate a GIT submodule (CPP code) for proprietary communication.

Is it possible to add the CPP module into existing C project and run?

Please assist.

This topic has been closed for replies.
Best answer by KnarfB

Create the STM32 project with C++ target language option. This enables both, C and C++.

hth

KnarfB

3 replies

KnarfB
KnarfBBest answer
Super User
August 8, 2022

Create the STM32 project with C++ target language option. This enables both, C and C++.

hth

KnarfB

Seenu
SeenuAuthor
Associate II
August 8, 2022

Thanks for the reply.

Is it possible to add the CPP files to existing STM32CubeIDE project?

KnarfB
Super User
August 8, 2022

AFAIR not. Create a new dummy STM32 C++ project, delete its sources and move the existing code into it?

hth

KnarfB

Bob S
Super User
August 8, 2022

It is possible to convert an existing project to use c and c++. In CubeIDE, select the desired project in the "Project Explorer" window. Right-click on the project and select "Convert to C++" (near the bottom of the menu).

You will need to update the project to find the new include files and new source files. To add include directories go to project properties, the "C/C++ Build-> Settings". Look for "Include Paths" and add your new include directory. Do this al ALL BUILD TYPES (i.e. debug and release) as well as both "MCU GCC Compiler" and "MCU C++ Compiler" settings. To add the source directory, in the project properties select "C/C++ General->Paths and Symbols". Click on the "Source Location" tab and add the folder with your new files.

Associate II
November 20, 2023

There is no such submenu in the current IDE (1.13.2)

AScha.3
Super User
November 20, 2023

1. for new -> project -> stm32project -> select cpu -> then:

AScha3_0-1700474658428.png

- give name + sel. c++

2. on existing project right mouse click -> on existing project

AScha3_1-1700474752418.png

- then choose : convert to c++

ok?

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