Go Down

Topic: collect2.exe: error: ld returned 5 exit status (Read 143537 times) previous topic - next topic

cjones7

Same problem here using 1.6.1 and 1.6.3 but ok with 1.6.0

Code that causes a compiler error is a division.

Example of occurance:
 int tim_delay = 500;
.
.
.
.
for (int i=1; i<= numleds; i++) {
     digitalWrite(ledpins, HIGH);
     delay (tim_delay/10);
}

If I change the denominator to a 2^n then no problem.

for (int i=1; i<= numleds; i++) {
     digitalWrite(ledpins, HIGH);
    delay (tim_delay/8);
}

Changing the code to:
for (int i=1; i<= numleds; i++) {
     digitalWrite(ledpins, HIGH);
     tim_delay = int(tim_delay/10)
    delay (tim_delay);

still causes the error.


mac2167

I am getting the same error.  I commented out delay(100); and compiled w/o the error!  Looking further.

cjones7

If I change:

 int tim_delay = 500;
.
.
for (int i=1; i<= numleds; i++) {
     digitalWrite(ledpins, HIGH);
     delay (tim_delay/10);
}

which generates a compiler error.

To:

 float tim_delay = 500.00;
.
.
.
.
for (int i=1; i<= numleds; i++) {
     digitalWrite(ledpins, HIGH);
     delay (int(tim_delay/10));
}

Then compiler error disappears.

DG2RDD

Same error message with simple comparisons between floats. Windows XP pro platform. I guess this is part of the problem. Code compiles fine with Uno card, does not with Leonardo. No visible syntaxerror (fairly simple code).
Currently trying to downgrade to version 1.6.0 of IDE.

Rx7man

I had the error message collect2.exe: error: ld returned 1 exit status

I closed Arduino IDE then I deleted all the consoleXXXXXXX.tmp, buildXXXXXXX.tmp, and untitledXXXXXXX.tmp folders in
c:\users\{username}\AppData\Local\Temp

Restarted Arduino IDE and I was all good to go again

Hope this helps someone

alv00

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.

CraigUnoR3

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.

Danny_v

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:

Code: [Select]

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.. :

Code: [Select]

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.


summerworm

Code: [Select]

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.

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..

jurs

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.

piroxilin

#26
Jun 18, 2015, 10:02 pm Last Edit: Jun 18, 2015, 10:03 pm by piroxilin
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.

AnalysIR

Quote
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.

I may be wrong, 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.

Oregu

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.

DrAzzy

Which version of the linker is that that you're recommending to replace it with?
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up