In my project I have simply started by adapting the ARMCM4-STM32F407-LWIP-FATFS-USB demo and adding new source files to the Makefile as needed. When I add code that uses the STL, it compiles, but I get these linker errors:
Code: Select all
In function `abort': abort.c:(.text.abort+0xa): undefined reference to `_exit'
In function `_kill_r': signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
In function `_getpid_r': signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
I'm using g++ as the linker rather than gcc. When I use gcc as the linker, I get different errors:
Code: Select all
In function `__gnu_cxx::new_allocator<std::_List_node<unsigned long> >::allocate(unsigned int, void const*)':
/home/hazelnusse/toolchain/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/include/c++/4.7.3/ext/new_allocator.h:94: undefined reference to `operator new(unsigned int)'
build/obj/main.o: In function `_M_insert<long unsigned int>':
/home/hazelnusse/toolchain/lib/gcc/arm-none-eabi/4.7.3/../../../../arm-none-eabi/include/c++/4.7.3/bits/stl_list.h:1534: undefined reference to `std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
I'm not sure if I need to use g++ for the link step (I don't think I need C++ runtime support, but maybe things like std::list do?).
I tried to build the g++ demos (ARM7-LPC214x-G++, and ARMCM3-STM32F103-G++) using the ARM GNU embedded toolchain but both are failing on ch.cpp with the following error:
Code: Select all
Compiling ../../os/various/ch.cpp
../../os/various/ch.cpp: In static member function 'static eventmask_t chibios_rt::Event::ClearFlags(eventmask_t)':
../../os/various/ch.cpp:290:32: error: 'chEvtClearFlags' was not declared in this scope
../../os/various/ch.cpp: In static member function 'static eventmask_t chibios_rt::Event::AddFlags(eventmask_t)':
../../os/various/ch.cpp:295:30: error: 'chEvtAddFlags' was not declared in this scope
../../os/various/ch.cpp:296:3: warning: control reaches end of non-void function [-Wreturn-type]
../../os/various/ch.cpp: In static member function 'static eventmask_t chibios_rt::Event::ClearFlags(eventmask_t)':
../../os/various/ch.cpp:291:3: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [build/obj/ch.o] Error 1
This is obviously not related to my issue but I thought I should point out that these two demos aren't building with a very standard toolchain.
If anybody is making extensive use of C++ in their embedded project with ChibiOS/RT, I'd love to see it.
Luke