Makefile issue when building C++ library in STMCubeIDE


After exporting a C++ library of my impulse and following this advice step-by-step (Build C++ Library with STM32CubeIDE), the console consistently outputs the following error:

make: *** No rule to make target ‘…/Core/Src/main.c’, needed by ‘Core/Src/main.o’. Stop.

My project has been converted to a C++ project, and I’ve renamed my main.c to main.cpp (this is precisely what causes the build error, because I can successfully build the project with main.c, granted without the C++ code included in the main.c source file, of course).

One of my assumptions is that, even though I can use STMCubeMX, and since I’m deploying a C++ library, I am NOT doing what is described in this tutorial here: When I try to import the CMSIS pack file and follow along with the rest of the tutorial, the build process generates about 1200 linker related errors that I think has to do with the two different ‘middlewares’ folders that CubeMX generates.

I think the solution I’m in need of involves updating the Makefile so that it knows to stop looking for main.c and to look for main.cpp instead, which I don’t know how to do. I’m not sure how to use the CMakesList.txt included in the exported zipfile either. I’d be grateful if anyone can help me with this.

The Makefile I’m using is large, but the only lines that I can find with ‘main’ are these:

All Target

all: main-build

Main-build Target

main-build: ProjName.elf secondary-outputs

Thank you!

Hi @Markrubianes can you email me your cubemx project at ?

Done. Thank you for taking a look!