cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add C++ Compiler in STM32CubeIDE for Mixed C/C++ Project?

Rima-Fahem
Associate II

Hello everyone,

I’m working on a project in STM32CubeIDE with C, and I’d like to add a C++ library. I’ve read that it’s possible to mix C and C++ using different compilers, but in my project settings (C/C++ Build > Settings > Paths and Symbols), I only see the GNU C compiler (arm-none-eabi-gcc).

How can I add the C++ compiler (arm-none-eabi-g++) in STM32CubeIDE?
Do I need to change any other settings to properly handle mixed C and C++ code in the project?

Thank you for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Right click the project in the Project Explorer and select "Convert to C++".

TDK_1-1742766931874.png

 

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

View solution in original post

3 REPLIES 3
TDK
Guru

Right click the project in the Project Explorer and select "Convert to C++".

TDK_1-1742766931874.png

 

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

Thank you for your reply!
I’d like to clarify — does "Convert to C++" change all my project files to C++, meaning main.c becomes main.cpp? Or does it just add the C++ compiler, allowing me to mix C and C++ in the same project?

> does it just add the C++ compiler, allowing me to mix C and C++ in the same project?

This one. No files are changed. CubeMX still generates C files.

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