Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By igrr
#2995 @jcmvbkbc
I've got linker errors that happen for some pieces of c++ code, but not for others. Not sure what exactly is triggering them.
While I'm trying to figure out the minimal example to reproduce those, could you please take a look at the errors?
Code: Select all/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(HardwareSerial.cpp.o):(.rodata._ZTI6Stream[typeinfo for Stream]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(HardwareSerial.cpp.o):(.rodata._ZTI14HardwareSerial[typeinfo for HardwareSerial]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(Print.cpp.o):(.rodata._ZTI5Print[typeinfo for Print]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-abort.o):(.literal+0x0): undefined reference to `_exit'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-abort.o): In function `abort':
abort.c:(.text+0x13): undefined reference to `_exit'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-signal.o):(.literal+0x0): undefined reference to `_getpid_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-signal.o):(.literal+0x4): undefined reference to `_kill_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-signal.o): In function `_raise_r':
signal.c:(.text+0x114): undefined reference to `_getpid_r'
signal.c:(.text+0x122): undefined reference to `_kill_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-mallocr.o):(.literal+0x1c): undefined reference to `_sbrk_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-mallocr.o): In function `malloc_extend_top':
mallocr.c:(.text+0x5e): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x127): undefined reference to `_sbrk_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-freer.o): In function `_malloc_trim_r':
mallocr.c:(.text+0x366): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x38f): undefined reference to `_sbrk_r'
/Users/igrokhotkov/projects/esp8266/arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/esp8266/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libc.a(lib_a-freer.o):mallocr.c:(.text+0x3a0): more undefined references to `_sbrk_r' follow
collect2: error: ld returned 1 exit status


I'm sure all the sbrk, getpid, kill, etc can be replaced with stubs (I'll do that), but what about "undefined reference to vtable for __cxxabiv1::__si_class_type_info"?
User avatar
By jcmvbkbc
#3004
igrr wrote:
Code: Select all/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(HardwareSerial.cpp.o):(.rodata._ZTI6Stream[typeinfo for Stream]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(HardwareSerial.cpp.o):(.rodata._ZTI14HardwareSerial[typeinfo for HardwareSerial]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/var/folders/15/ybtbgzpj7636vv4wp92l2c700000gn/T/build859463475789359941.tmp/core.a(Print.cpp.o):(.rodata._ZTI5Print[typeinfo for Print]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'


I'm sure all the sbrk, getpid, kill, etc can be replaced with stubs (I'll do that), but what about "undefined reference to vtable for __cxxabiv1::__si_class_type_info"?

Looks like it needs to be compiled with -fno-rtti. Can you share the code and build commands?
User avatar
By igrr
#3012
jcmvbkbc wrote:Looks like it needs to be compiled with -fno-rtti. Can you share the code and build commands?

Disabling rtti helped.
As for the other errors, turned out some Arduino libraries called malloc, free, and abort. Replacing those with calls to functions from espressif SDK helped. But this is not a very robust solution as the user can legitimately include <stdlib.h> in his sketch and call malloc, which will result in linker error. So I guess these newlib functions have to be replaced or overridden in this case.
User avatar
By martinayotte
#3017 Hi igrr,
What are you cooking in your jar ? :)
We don't what it is, but it smell good ... :D