Hello,
I'm encountering a problem when using chprintf in a C++ project, i.e. modifying the RT-STM32F407-DISCOVERY-G++ example by including the appropriate src & inc and inserting in the main loop the following immediate after the sleep:
chprintf((BaseSequentialStream*)&SD2, "Hello");
The linker gives the following errors:
Linking build/ch.elf
build/obj/main.o: In function `chprintf':
C:\ChibiStudio\workspace30\RT-STM32F407-DISCOVERY-G++-Shell/../../chibios3/os/hal/lib/streams/chprintf.h:77: undefined reference to `__cxa_end_cleanup'
build/obj/main.o:(.ARM.extab.text._ZL8chprintfP20BaseSequentialStreamPKcz+0x0): undefined reference to `__gxx_personality_v0'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1
A quick GOOGLE search hints to using g++ instead of gcc for linking.
But in the make file is a hint not to do so:
Code: Select all
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
LD = $(TRGT)gcc
#LD = $(TRGT)g++BTW: using g++ instead of gcc leads to even more error messages:
Code: Select all
Linking build/ch.elf
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
c:/chibistudio/tools/gnu tools arm embedded/4.7 2014q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2.exe: error: ld returned 1 exit status
make: *** [build/ch.elf] Error 1These errors look like syscalls related!?
Any idea for a workaraound, keeping gcc for linking?
Best regards
~wolf