Error compiling write_r, read_r, etc library link errors

I am just getting back to being able to mess with my Electron module. I had it working when I first received it but now when I compile the same code (after changing Spark. functions to Particle. ) I receive link errors and don’t know where to go. All the functions that it is complaining about are io related but I don’t know which library or code is the cause. I am just using the neopixel library and Wire functions. This is the errors I am receiving, I also tried clearing the cache (using the online build).

/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-writer.o): In function _write_r': writer.c:(.text._write_r+0x10): undefined reference to_write’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-closer.o): In function _close_r': closer.c:(.text._close_r+0xc): undefined reference to_close’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-fstatr.o): In function _fstat_r': fstatr.c:(.text._fstat_r+0xe): undefined reference to_fstat’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-isattyr.o): In function _isatty_r': isattyr.c:(.text._isatty_r+0xc): undefined reference to_isatty’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.a(lib_a-lseekr.o): In function _lseek_r': lseekr.c:(.text._lseek_r+0x10): undefined reference to_lseek’
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/bin/…/lib/gcc/arm-none-eabi/4.8.4/…/…/…/…/arm-none-eabi/lib/armv7-m/libg_s.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: *** [44db63e0a098c7665507c8bb52a71460c3bbe0c503703250896574fdcf93.elf] Error 1

1 Like

I found the problem after googling for other similar issues. I had one “printf” function in the code (I guess where I was porting something) and it was causing the errors.

2 Likes

I’m getting this error using sprintf(), can you share how you resolved this issue?

This error should not occur for sprintf. I use sprintf and snprintf all the time.

Are you sure you don’t have one accidental printf instead of sprintf somewhere in your code?

1 Like

Yes, I have 4 sprintf() statements. Before adding my own library, the code compiled fine. Now, it does not.

Does your library contain any printf statements? Basically, that’s the error you get if there’s a printf (not sprintf) call anywhere in the compiled code.

None. I even commented out the four sprintf() statements and it still isn’t compiling. I’m not entirely sure what it doesn’t like.

Also: printf, fprintf, vprintf, vfprintf, scanf, fscanf, vscanf, vfscanf, fopen, fread, fwrite, fclose, fflush, fgetc, and many more.

Pretty much every function in this page will cause a similar problem:

It’s because I had included:
#include <iostream>
:dizzy_face:

Thank you for your help!

2 Likes

I had a similar issue, and the problem was within a printf statement. I was attempting to print a char array as a C String, and it required a char*.

I also had this error, but it was unrelated to any print calls or stream headers.

A lib I’m using compared a string to nullptr.
Some of the libs assertions from <cassert> also threw this error.

Removing str != nullptr and some of the assertions against booleans allowed me to successfully compile.