undefined reference to `__rw::__rw_deallocate - EthernetNetIf library

06 Nov 2012

Hi mbed,

I am facing a problem when trying to build my current project offline using GCC. Everything seems to compile just fine until it tries to compile the EthernetNetIf.a library. (We are still using the old Ethernet library). For some reasons, there are tones of undefined references to _rw_deallocate etc.. I believe those are low functions of C code but I have no idea why they are undefined. Maybe I am missing a library ?

ps: my project compile fine on mbed.org.

Here is the output log of my build:

./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o): In function `Net::~Net()':
..\fwk\core\net.cpp:(.text+0xf4): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\core\net.cpp:(.text+0xfe): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\core\net.cpp:(.text+0x192): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\core\net.cpp:(.text+0x19c): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\core\net.cpp:(.text+0x230): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o):..\fwk\core\net.cpp:(.text+0x23a): more undefined references to `__rw::__rw_deallocate(void*, unsigned int, int)' follow
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o): In function `std::list<NetUdpSocket*, std::allocator<NetUdpSocket*> >::_C_get_node(bool)':
..\fwk\core\net.cpp:(t._ZNSt4listIP12NetUdpSocketSaIS1_EE11_C_get_nodeEb[std::list<NetUdpSocket*, std::allocator<NetUdpSocket*> >::_C_get_node(bool)]+0x3c): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
..\fwk\core\net.cpp:(t._ZNSt4listIP12NetUdpSocketSaIS1_EE11_C_get_nodeEb[std::list<NetUdpSocket*, std::allocator<NetUdpSocket*> >::_C_get_node(bool)]+0x4a): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o): In function `std::list<NetTcpSocket*, std::allocator<NetTcpSocket*> >::_C_get_node(bool)':
..\fwk\core\net.cpp:(t._ZNSt4listIP12NetTcpSocketSaIS1_EE11_C_get_nodeEb[std::list<NetTcpSocket*, std::allocator<NetTcpSocket*> >::_C_get_node(bool)]+0x3c): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
..\fwk\core\net.cpp:(t._ZNSt4listIP12NetTcpSocketSaIS1_EE11_C_get_nodeEb[std::list<NetTcpSocket*, std::allocator<NetTcpSocket*> >::_C_get_node(bool)]+0x4a): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o): In function `std::list<NetIf*, std::allocator<NetIf*> >::_C_get_node(bool)':
..\fwk\core\net.cpp:(t._ZNSt4listIP5NetIfSaIS1_EE11_C_get_nodeEb[std::list<NetIf*, std::allocator<NetIf*> >::_C_get_node(bool)]+0x3c): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-core-net.cpp.o):..\fwk\core\net.cpp:(t._ZNSt4listIP5NetIfSaIS1_EE11_C_get_nodeEb[std::list<NetIf*, std::allocator<NetIf*> >::_C_get_node(bool)]+0x4a): more undefined references to `__rw::__rw_allocate(unsigned int, int)' follow
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-nettcpsocket.cpp.o): In function `std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::push_back(NetTcpSocketEvent const&)':
..\fwk\if\net\nettcpsocket.cpp:(t._ZNSt5dequeI17NetTcpSocketEventSaIS0_EE9push_backERKS0_[std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::push_back(NetTcpSocketEvent const&)]+0xa6): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-nettcpsocket.cpp.o): In function `std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::pop_front()':
..\fwk\if\net\nettcpsocket.cpp:(t._ZNSt5dequeI17NetTcpSocketEventSaIS0_EE9pop_frontEv[std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::pop_front()]+0x28): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\if\net\nettcpsocket.cpp:(t._ZNSt5dequeI17NetTcpSocketEventSaIS0_EE9pop_frontEv[std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::pop_front()]+0x52): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-nettcpsocket.cpp.o): In function `std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::~deque()':
..\fwk\if\net\nettcpsocket.cpp:(t._ZNSt5dequeI17NetTcpSocketEventSaIS0_EED1Ev[std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::~deque()]+0x2c): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\if\net\nettcpsocket.cpp:(t._ZNSt5dequeI17NetTcpSocketEventSaIS0_EED1Ev[std::deque<NetTcpSocketEvent, std::allocator<NetTcpSocketEvent> >::~deque()]+0x56): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-netudpsocket.cpp.o): In function `std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::push_back(NetUdpSocketEvent const&)':
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9push_backERKS0_[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::push_back(NetUdpSocketEvent const&)]+0x1a): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9push_backERKS0_[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::push_back(NetUdpSocketEvent const&)]+0x2c): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9push_backERKS0_[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::push_back(NetUdpSocketEvent const&)]+0x7c): undefined reference to `__rw::__rw_allocate(unsigned int, int)'
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9push_backERKS0_[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::push_back(NetUdpSocketEvent const&)]+0xa6): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-netudpsocket.cpp.o): In function `std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::pop_front()':
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9pop_frontEv[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::pop_front()]+0x28): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EE9pop_frontEv[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::pop_front()]+0x52): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
./lib/EthernetNetIf/LPC1768\libEthernetNetIf.a(fwk-if-net-netudpsocket.cpp.o): In function `std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::~deque()':
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EED1Ev[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::~deque()]+0x2c): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
..\fwk\if\net\netudpsocket.cpp:(t._ZNSt5dequeI17NetUdpSocketEventSaIS0_EED1Ev[std::deque<NetUdpSocketEvent, std::allocator<NetUdpSocketEvent> >::~deque()]+0x56): undefined reference to `__rw::__rw_deallocate(void*, unsigned int, int)'
c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: build.elf: hidden symbol `__2printf' isn't defined
c:/program files (x86)/gnu tools arm embedded/4.6 2012q2/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [build.elf] Erreur 1

Thanks for your help.

15 Nov 2012

In the EthernetNetIf library, functions rw_allocate and rw_deallocate appears as: _ZN4rw15rw_deallocate and _ZN4rw13rw_allocate. Could there be an issue with renaming of those functions and is there an option in GCC to bypass this issue ?

The project appears to compile fine, but the references are undefined for the linker, is there another library that needs to be linked with EthernetNetIf in order to get it working with GCC ? Or should rw_deallocate and rw_allocate appears in system libraries ? We are currently linking -lstdc++ -lsupc++ -lm -lgcc -lc -lgcc -lc -lnosys and the ethernetNetIf library.