Compilation Error "collect2: error: ld returned 1 exit status"


I have the error below while compiling a sketch.
I can isolate the function (library call) that is generating these error, however this library works perfectly with other program.
This is independent of the Arduino Version (at least before 1.6.6)
Any Idea where to start to look for?

Thanks in advance

Applications/Arduino In function isspace': (.text.avr-libc+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol __ctype_isfalse' defined in .text.avr-libc section in /Applications/Arduino
collect2: error: ld returned 1 exit status

OK, there is probably a bug somewhere in the Arduino code (who I am to say that!).

This problem occurs when I combine two specific functions in the same script (each function is working well separately)
The functions are:

  • string.toFloat()
  • stream.readBytesUntil(character, buffer, length)

I did solve the problem by rewriting the most exotic one: string.ToFloat().


Would you mind posting a simple code example that reproduces this issue? I just tried:

String stringOne;
void setup() {
  stringOne = String("1.23");
  float x=stringOne.toFloat();
  char serialBuffer[25];
  Serial.readBytesUntil(10, serialBuffer, 24);
void loop() {}

With Arduino IDE 1.6.5r5 and it compiles fine.

This is an avr-libc bug.

About an example ....

I am afraid that this is very difficult.
It is part of an complex sketch that includes TCP/IP MQTT Client string parsing (reason of conversion from string to float) and the activation of a TCP/IP server transfer which is using the streaming function to read bytes from a TCP Client.