odd exit status 1 when upload (urgent)

so i have been working on my first small urdunio project and its required a color sensor, after doing some research i finally finish the code to make it work, that is when it happened.
It keep giving me this "collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno."
without even point out what line caused the bug. i ve googled it but non of those topic that i found seems to be ablr to fix it...
As a student and i really want to learn more about programing with ardunio.

#include <Servo.h>
#define SO 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8
int frequency = 0;
Servo servo;
void setup()
{
// servo.attach(8);
// servo.write(0);
// delay(2000);
pinMode(SO, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);

digitalWrite(SO, HIGH);
digitalWrite(S1, LOW);

Serial.begin(9600);
}

void loop()
{
// servo.write(90);
// delay(1000);
// servo(0);
// delay(1000);
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);

frequency = pulseIn(sensorOut, LOW);

Serial.print("R= ");
Serial.print(frequency);
Serial.print(" ");
delay(100);

digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);

frequency = pulseIn(sensorOut, LOW);

Serial.print("G= ");
Serial.print(frequency);
Serial.print(" ");
delay(100);

digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);

frequency = pulseIn(sensorOut, LOW);

Serial.print("R= ");
Serial.print(frequency);
Serial.print(" ");
delay(1000);
}

When I compile your improperly posted code, I get:

Sketch uses 6,278 bytes (21%) of program storage space. Maximum is 28,672 bytes.
Global variables use 206 bytes (8%) of dynamic memory, leaving 2,354 bytes for local variables. Maximum is 2,560 bytes.

So, you need to tell us what board you are compiling for, using what version of the IDE, on what operating system.

Compiles OK for me

Sketch uses 3,876 bytes (12%) of program storage space. Maximum is 32,256 bytes.
Global variables use 235 bytes (11%) of dynamic memory, leaving 1,813 bytes for local variables. Maximum is 2,048 bytes.

Win 7
IDE 1.5.6-r2
Arduino Uno

board UNO, Ardunio 1.8.1.0 on windows 10

That seems a common problem on Windows XP system when using a later IDE (not sure which version). Do a search and include the keyword xp in the search.

There seems to be a solution (maybe the nightly build ).

PS might also apply to Win10.

A bunch of people have had IDE problems, including IDE crashes and bizarre compile errors, when they install a new version of the IDE. At least some of those problems seem to be caused by incompatible executables and preference files that the IDE saves outside the IDE installation directory. Perhaps that is what is causing your particular problem. In such cases it appears that the fix is to delete or rename the old "Arduino15" directory and re-install the new IDE.

On Mac OS X:
/Users/(username)/Library/Arduino15 (a.k.a. ~/Library/Arduino15)
(Note: The 'Library' folder is greyed out in Finder. The folder can't be opened with a double-click. To browse the contents of 'Library', ctrl-click on it and select "Open in New Tab" from the pop-up menu.)

On Windows delete or rename both:
Arduino IDE 1.6.5r5 and previous: C:\Users(username)\AppData\Roaming\Arduino15
Arduino IDE 1.6.6 and later: C:\Users(username)\AppData\Local\Arduino15

On Linux:
/home/(username)/.arduino15 (a.k.a. ~/.arduino15)
(Note: file/folder names starting with '.' are not normally shown in directory listings. Use 'ls -a' to get a directory listing that includes the hidden files.)

johnwasser:
A bunch of people have had IDE problems, including IDE crashes and bizarre compile errors, when they install a new version of the IDE. At least some of those problems seem to be caused by incompatible executables and preference files that the IDE saves outside the IDE installation directory. Perhaps that is what is causing your particular problem. In such cases it appears that the fix is to delete or rename the old "Arduino15" directory and re-install the new IDE.

On Mac OS X:
/Users/(username)/Library/Arduino15 (a.k.a. ~/Library/Arduino15)
(Note: The 'Library' folder is greyed out in Finder. The folder can't be opened with a double-click. To browse the contents of 'Library', ctrl-click on it and select "Open in New Tab" from the pop-up menu.)

On Windows delete or rename both:
Arduino IDE 1.6.5r5 and previous: C:\Users(username)\AppData\Roaming\Arduino15
Arduino IDE 1.6.6 and later: C:\Users(username)\AppData\Local\Arduino15

On Linux:
/home/(username)/.arduino15 (a.k.a. ~/.arduino15)
(Note: file/folder names starting with '.' are not normally shown in directory listings. Use 'ls -a' to get a directory listing that includes the hidden files.)

Thank for your help but i cant find the appdata file in my username file and im on win 10.

UKHeliBob:
Compiles OK for me

Sketch uses 3,876 bytes (12%) of program storage space. Maximum is 32,256 bytes.

Global variables use 235 bytes (11%) of dynamic memory, leaving 1,813 bytes for local variables. Maximum is 2,048 bytes.




Win 7
IDE 1.5.6-r2
Arduino Uno

when i open board info.
it show this
"BN: Unknown board
VID: 1A86
PID: 7523
SN: Upload any sketch to obtain it"
unknown board is odd maybe it explain something?
btw thank you very much

Tried many method, still no result, is that because of the board or other reasons? Any idea?