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

Hi,

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
Robert

Applications/Arduino 1.6.5-r5.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6/libc.a(isspace.o): 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 1.6.5-r5.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/lib/avr6/libc.a(cty_isfalse.o)
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().

Robert

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

String stringOne;
void setup() {
  Serial.begin(9600);
  stringOne = String("1.23");
  float x=stringOne.toFloat();
  Serial.print(x);
  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.

http://savannah.nongnu.org/bugs/?33698

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.

Robert