collect2.exe: error: ld returned 5 exit status
I am getting this error on Arduino 1.6.1, Windows XT on different and apparently benign code. Could not figure out any obvious reason. The error comes from the linker and I have not found any information about what that exit code means.
But this workaround helps to compile the program. I have Visual C++ installed on my machine, so when this error happens, a window pops up saying "ld.exe has encountered a problem and needs to close". I push the Debug button and VC++ debug window opens. I just close the debugger and voila, Arduino finishes the build successfully like nothing happened. I uploaded it into my Nano, everything works fine.