[ resolved ] ld returned 5 exit status - only compiles when serial is used

Arduino: 1.6.5 (Windows XP), Board: "Arduino Nano, ATmega328"

collect2.exe: error: ld returned 5 exit status
Error compiling.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

clone NANO, USBasp selected for programmer
CH340 for the USB driver.

======================================

I need to use A3 as a digital input. I have a remote switch and have used all my other pins. only A2 and A3 are unused.

I have been stripping everything out to find he error and have it down to this.

this code reports the error as listed above.
however, when I remove the comments from the 3 serial line (1 in setup, 2 in loop)
the program compiles and runs.

//const int buttonPin = A3;
const int ledPin13 = 13;

int keyState = 0;
int buttonState = 0;

void setup() {
  //  pinMode(buttonPin, INPUT);
  pinMode(ledPin13, OUTPUT);
  // Serial.begin(9600);
}

void loop() {
  buttonState = digitalRead(A3);

  if (buttonState == HIGH) {
    digitalWrite(ledPin13, HIGH);
  }
  else {
    digitalWrite(ledPin13, LOW);
  }

  //Serial.print(buttonState);
  //Serial.println();

}

You code compiles without problems in both variants.
IDE 1.6.5, Win7, Nano-clone with CH340G.

What if you use 17 instead of A3, and byte throughout instead of int? (no values are above 255, so int is not needed)

[pre][code]const byte buttonPin = 17;
const byte ledPin13 = 13;

byte keyState = 0;
byte buttonState = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin13, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    digitalWrite(ledPin13, HIGH);
  }
  else {
    digitalWrite(ledPin13, LOW);
  }

  Serial.print(buttonState);
  Serial.println();

}

[/code]

I started with boolean, then went to the button example, that is how I wound up with int.

started the pc when I came home, loaded the ide and it failed.
re-loaded the ide, loaded my test and the ide crashed
re-re-loaded the ide, re-loaded my sketch, and got a windoze error.

opened add/remove programs and did a little housekeeping, removed some old programs
rebooted

opened the ide, (opened properly)
replaced all int with byte
compiled. yeah !

at this point, I think I had a conflicting program or some such,
but it compiled and that was my need.

thanks all that posted. I marked the thread resolved.