I try to convert my project to C++ in TrueSTUDIO for STM32 by
Than nothing happens, when I change main.c to main.cpp, I get the following error after build:
startup\startup_stm32f407xx.o: In function `LoopFillZerobss':
C:\Users\Michel\OneDrive\Stm32\Stm32CubeProjects\Fcb1010\Debug/..\startup/startup_stm32f407xx.s:115: undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
It seems still C is used (also in the command line (first part):
arm-atollic-eabi-gcc -o Fcb1010.elf Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.o Drivers\STM ...
I would expect g++ to be used.
How to change my settings/procedure to be able to use C++ within TrueSTUDIO for a CubeMX generated project?
UPDATE
I removed Atollic TrueStudio, removed AC6 System Workbench, and reinstalled AC6 System Workbench. Now I can use C++ at AC6 System Workbench, even using STL.
I do not dare to install Atollic TrueStudio again, since it breaks the existing installation of AC6 SystemWorkbench, probably because they both use Eclipse. A pity, since I liked some features of TrueStudio, but C++ is more important to me. So for me, no TrueStudio anymore.
The error you mention
startup\startup_stm32f407xx.o: In function 'LoopFillZerobss': C:\Users\Michel\OneDrive\Stm32\Stm32CubeProjects\Fcb1010\Debug/..\startup/startup_stm32f407xx.s:115: undefined reference to `main' collect2.exe: error: ld returned 1 exit status
Is a linker problem, I suspect the library is looking for a c main function. A C++ compiler performs name mangling, so the symbol will no longer be main
.
Try changing the signature of your main
to extern "C" int main(void)
Please follow below steps:-
Hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With