if statement error when compile

hi
I am a beginer on Arduino, I am writing a code to recieve strings from Serial port 1 and based on the recieved string take desisions with if statements but I got this error when I compiled it:

C:\Archivos de programa\Arduino\hardware\tools\avr/bin/avr-gcc" -Wall -Wextra -Os -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "C:\DOCUME~1\Usuario\CONFIG~1\Temp\build825a98ccc64aba288ba8b5f13fe878b9.tmp/tombotv1.ino.elf" "C:\DOCUME~1\Usuario\CONFIG~1\Temp\build825a98ccc64aba288ba8b5f13fe878b9.tmp\sketch\tombotv1.ino.cpp.o" "C:\DOCUME~1\Usuario\CONFIG~1\Temp\build825a98ccc64aba288ba8b5f13fe878b9.tmp/core\core.a" "-LC:\DOCUME~1\Usuario\CONFIG~1\Temp\build825a98ccc64aba288ba8b5f13fe878b9.tmp" -lm
collect2.exe: error: ld returned 5 exit status

exit status 1
Error compilaciĆ³n en tarjeta Arduino/Genuino Mega or Mega 2560.

I tested deleting the if statements and compilation works fine, I found that I got the same error when I wrote under the if statement digitalWrite or call a function.

ARDUINO IDE: 1.6.10
PC with windows XP
Here it is the code:

//sketch to control 2 DC motors using L298N and reciving the data at serial 1.
int PWM_A = 2; //ENA
int MotorDer1 = 3; //IN1
int MotorDer2 = 4; //IN2
int MotorIzq1 = 5; //IN3
int MotorIzq2 = 6; //IN4
int PWM_B = 7; //ENB
int Luces=8;
String bufferString;
int velocidad = 150; // variable para velocidad
void setup() {
//configuracion pines control motores
pinMode(PWM_A, OUTPUT);
pinMode(MotorDer1, OUTPUT);
pinMode(MotorDer2, OUTPUT);
pinMode(MotorIzq1, OUTPUT);
pinMode(MotorIzq2, OUTPUT);
pinMode(PWM_B, OUTPUT);
// configuracion luces
pinMode(Luces,OUTPUT);
// Configuracion puerto serie
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
// verifica si hay datos en el serial 1,almacena en una variable

if(Serial1.available() >0){
delay(20);
String bufferString="";
while (Serial1.available() >0){
bufferString +=(char)Serial1.read();
}
{Serial.print("recibi: ");
Serial.println(bufferString);}
if (bufferString == "FWD"){
go_fwd();
}
}

}
// subrutinas de giro,avance o retroceso

void go_fwd(){
// MDer sentido horario,MIzq antihorario
digitalWrite(MotorDer1,LOW);
digitalWrite(MotorDer2,HIGH);
digitalWrite(MotorIzq1,LOW);
digitalWrite(MotorIzq2,HIGH);
analogWrite(PWM_A,200);
analogWrite(PWM_B,200);

}
void reversa(){
// MDer antihorario,Mizq horario
digitalWrite(MotorDer1,HIGH);
digitalWrite(MotorDer2,LOW);
digitalWrite(MotorIzq1,HIGH);
digitalWrite(MotorIzq2,LOW);
analogWrite(PWM_A,200);
analogWrite(PWM_B,200);
}
void izquierda(){
// MDer y MIzq antihorario
digitalWrite(MotorDer1,LOW);
digitalWrite(MotorDer1,HIGH);
digitalWrite(MotorIzq1,HIGH);
digitalWrite(MotorIzq2,LOW);
analogWrite(PWM_A,200);
analogWrite(PWM_B,200);
}

void derecha(){
// MDer y MIzq sentido horario
digitalWrite(MotorDer1,HIGH);
digitalWrite(MotorDer2,LOW);
digitalWrite(MotorIzq1,LOW);
digitalWrite(MotorIzq2,HIGH);
analogWrite(PWM_A,200);
analogWrite(PWM_B,200);
}
void parar(){
digitalWrite(MotorDer1,LOW);
digitalWrite(MotorDer2,LOW);
digitalWrite(MotorIzq1,LOW);
digitalWrite(MotorIzq2,LOW);
analogWrite(PWM_A,200);
analogWrite(PWM_B,200);
}

void luces_on(){
digitalWrite(Luces,HIGH);
}

void luces_off() {
digitalWrite(Luces,LOW);
}

I will appreciate some help!!
Regards

Your code compiles and links fine (tried with IDE 1.6.7, which is not one of the better versions).

Get rid of 1.6.10 and use either 1.6.9 or 1.6.5. If you do a search, you might find instruction how to remove it completely.

PS:
Next time, please post your code using code tags

type
** **[code]** **

paste your code after that
type
** **[/code]** **
after the pasted code
So it looks like

your code here

Welcome :slight_smile:

This is known bug with newer Arduino IDE versions running on Win XP. You can try the workarounds described here, or you can use an older version of IDE or a newer version of Windows.

Hi
I appreciate your help.
I tried the workarounds mentioned by guix but no changes, so I will unistall the IDE 1.6.10 and install an older version.
I think I can unistall itt from add/remove programs isn`t it?
Regards

Jus a comment I used IDE 1.6.9 and works fine at the moment.
Regards