Flatbuffers compile error

Hello,
I’m trying to compile code which uses Flatbuffers but following error occurs:

/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
../../../build/module.mk:183: recipe for target '../../../build/target/user-part/platform-6-m/proto_test.elf' failed
make[1]: Leaving directory '/home/flavio/git/particle-firmware/modules/photon/user-part'
/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-lseekr.o): In function `_lseek_r':
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
/usr/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv7-m/libg_nano.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
collect2: error: ld returned 1 exit status
make[1]: *** [../../../build/target/user-part/platform-6-m/proto_test.elf] Error 1
make: *** [modules/photon/user-part] Error 2

It should be something related to in/out functions.

How can I resolve this issue?

Thank you

Okay,
I have fixed it adding COMPILE_LTO=y in make arguments as seen here 0.4.0 firmware available (pre-release)

I’m seeing the same issue in my project. How did you add this extra compiler flag?

Thanks!

These errors (_read, _write, _close, _fstat, etc.) generally indicate that you are trying to use printf type functions but there is no file system or IO infrastructure on these small boards. The best way to fix this is to change printf() to debug log calls or serial prints or some other thing, not to change a compiler flag.

3 Likes