collect2.exe: error: ld returned 5 exit status

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.

I got this same message type when I tried to compile the test program for an LCD keyboard. I was using version 1.6.4.

After looking around, somewhere I read a suggestion to try using an older version. After banging my head against the wall, I installed version 1.0.6 and viola! good compile and it worked as advertised.

I really didn't want to go backward in software version, so I downloaded the 1.6.5 Hourly build 2015/06/06 3:34. It worked correctly, the software compiled, loaded and run correctly.

So, my guess is it's a problem with a few versions, including 1.6.4. Apparently, it seems be fixed in the coming version.

The real question is, "How close is the beta to being done?"

I hope this gives a new perspective to the problem.

Seems to be a (random) integer division bug in the compiler. (tested with 1.6.4 on XP here)

For example, if you have this:

int someValue = 123;

someFunction(someValue / 50);

it will probably compile fine (as it should!)

Now if you comment out or change some totally unrelated code elsewhere in your program (or change some #define), sd.exe might crash with the same code above.. (what makes is very hard to find the real problem - or better: there isn't a problem in your code at all..).

Now, if you make some changes to the call to someFunction(), it will compile again.. :

someFunction(someValue / 50.0);  // -> Ok

someFunction(someValue / 16);  // -> Ok (power of 2, where the compiler uses a shift)

someFunction(someValue / (float)50);  // -> Ok (in case you're using a variable)

someFunction((byte)someValue / 50);  // -> Ok

someFunction((byte)someValue / 0);  // -> Never do that! :)

In other words: as long as the whole division is not integer, it seems to compile fine.

int i=0;
int k=0;
//float a=200.00; //1
//int b=200;  //1
int x;  //1

void setup(){
  pinMode(4,INPUT);
  pinMode(6,OUTPUT);
  Serial.begin(9600);
}

void loop(){
  if(digitalRead(4)){
    if(k==0){
      i=i+5;
    }else if(k==1){
      i=i-5;
    }
    analogWrite(6,i);
    Serial.print(i);  //3
    Serial.print("\n"); //3
    Serial.println(i);  //3-3
  }
  if(i>35){
    k=1;
  }else if(i<5){
    k=0;
  }
  //delay(int(a/10)); //
  //delay(a/10); //
  //delay(200/10); //1-1
  delay(200); //1-1
}

Also strange error, if the number line 1 notes, 1-1 will go wrong, if the number line 3 notes, 3-3 will go wrong. Latest edition,arduino 1.6.5 hourly build 2015/06/12 11:42.

Had the same problem on 1.6.4 when using code from starterkit, so there shouldn´t be any problem with it.. solutions suggested here didn´t work for me, at the end this advice did:

https://github.com/arduino/Arduino/issues/2989

I just had to add four variables, not three..

Quajii: Had the same problem on 1.6.4 when using code from starterkit, so there shouldn´t be any problem with it.. solutions suggested here didn´t work for me, at the end this advice did:

https://github.com/arduino/Arduino/issues/2989

I just had to add four variables, not three..

I'd give the advice: Update your Windows operating system to Windows 7 or higher.

Windows XP is outdated! Nobody cares if new software versions do not work with Windows XP which was released in the year 2001.

Arduino 1.0.5 works with Windows XP. So if you want to use ancient Windows XP versions, stay with old Arduino 1.0.5.

Or upgrade your Windows operating system to Windows 7 at least.

I delete LD.EXE from C:\Program Files\Arduino\hardware\tools\avr\avr\bin (version 1.6.5) and replace it with LD.EXE from arduino 1.0.5 ver.

All errors ("ld returned 5 exit status") are gone.

Nobody cares if new software versions do not work with Windows XP which was released in the year 2001.

@jurs Actually, I do!

..From Wikipedia....Last release 2008....EOL announced 2009....unpaid support from MS ended 2014

Presumably sold for some time after that.

[u]I may be wrong[/u], but I haven't noticed an announcment from 'Arduino' that the IDE is no longer supported on XP. However, I would encourage everyone to upgrade from XP to any Vendor's more recent OS.

I got this same problem when I tried to compile my different sketchs. I was using version 1.6.2 and 1.6.5.-r2 on computers with WinXP Home edition and Win XP Prof. This problem does not depend on compiled code. I fix this problem by install arduino ide 1.6.5.r2 and replace file ld.exe. You can download this file from this webpage: http://oregu.ru/myfiles/arduino_fix. This file placed in %Arduino%/hardware/tools/avr/avr/bin/ld.exe. %Arduino% - folder, where installed Arduino IDE. I tested this solution for a few hours on various sketches and no errors occur.

Which version of the linker is that that you're recommending to replace it with?

I can not say for sure, because experiments ended late at night)) This file is obtained from the package Arduino Ide 1.5.x version, but a version of it is not remember, but not the first and not the latest version 1.5.

Oregu: You can download this file from this webpage: http://oregu.ru.

Just in case anybody was thinking of downloading an EXE from an UNTRUSTED source... DON'T DO THIS.

Do what piroxilin suggested: download and install Arduino IDE 1.0.5 (or others, like 1.5.x?) in a separate directory, then copy the 1.0.5 ld.exe file into the 1.6.x hardware\tools\avr\avr\bin directory.

For Windows, if the old install associates the old IDE with .INO files, do a right-click -> open with -> Choose Default Program... and navigate to the 1.6.x install directory to find the Arduino.EXE.

Stay safe! /dev

Hello Eveyone, I was facing the same problem with while compiling example code given alongwith the Utouch library of Henning Karlsen. I ran 1.6.3 Arduino with compatibility of Windows98/WindowsME and suprisingly it complied smoothly. Hope it eases the trouble faced by you all !

P.S : Running Windows XP SP2

I tried what /dev suggested, and it worked!

I used the ld.exe file from v1.0.5

Thanks /dev, you have helped a first time user get past this frustrating error, and into "learning mode". Your help is greatly appreciated.

Hi,

I had the same problem using 1.6.5 on my Windows XP and decided to downgrade Arduino software to 1.6.0.

This solved the problem and I also noticed that the file size for 1.6.0 (93,5mb) was larger than 1.6.5 (77mb)

Not sure if this has anything to do with it.

Good Luck!!

I am trying to load some new firmware on my Lulzbot 3D TAZ 4 printer. I have read the Lulzbot documentation and the documentation on this forum for doing the Arduino verify and compile for uploading this software, but I can't get pass the verify/compile of the code. The following is the error that I get:

C:\Program Files (x86)\Arduino\libraries\Marlin_2015Q1_TAZ5_0/ultralcd.cpp:738: multiple definition of `u8g_dev_st7920_128x64_rrd_buf' ultralcd.cpp.o:C:\Users\user\AppData\Local\Temp\build7762107252506360423.tmp/ultralcd.cpp:738: first defined here collect2.exe: error: ld returned 1 exit status Error compiling.

I have downloaded the Lulzbot Ardunio firmware add-on-files that are needed I have downloaded the TAZ 5 firmware for the hexagon hot end I am running version 1.6.5 of IDE This software run on many other Lulzbot 3D printers so I'm sure the firmware code is correct, I'm just not sure what I am doing wrong. This software contains a lot of files and programs, I think I have everything in the right place, but apparently something is not correct.

I can compile and upload arduino firmware for other cards with no problem.

I am hoping that someone on this forum can help me.

rishrsoni:
Hello Eveyone,
I was facing the same problem with while compiling example code given alongwith the Utouch library of Henning Karlsen. I ran 1.6.3 Arduino with compatibility of Windows98/WindowsME and suprisingly it complied smoothly. Hope it eases the trouble faced by you all !

P.S : Running Windows XP SP2

It works! Thanks!

Hey, just check your code from Design #1 - Design #12.

In Design #4, I found the random number generator caused a problem (Didn't use that code) and in Design #5, I found that removing the "const" let it compile.

Ir's not "right", but you have to compare working Designs w/non-working Designs.

For all of you that use Arduino 1.6.5 on Windows XP, I could suggest to change TMP and TEMP system variable definition (System Properties => Advanced => Environment Variables)

By default they are defined as %USERPROFILE%\Local Settings\Temp You could create a Temp directory on C drive and set both variable to C:\Temp

As Linkers are generally sensitive on paths content, it is advised to set simpler and shorter paths.

On my side this change solve all "collect2.exe: error: ld returned 5 exit status" errors I have on all Arduino projects with 1.6.5 release.

Have a good works!

So, what is the fix? Is Windows XP limited to older versions of the Arduino IDE? Or is there going to be a fix sometime soon?