What does collect2 error ld returned 1 exit status mean

0 votes

I see the error collect2: error: ld returned 1 exit status very often. For example, when I was executing the following snippet of code I got the following:-

void main() { 
    char i; 

      printf("ENTER i"); 
      scanf("%c",&i); 

      clrscr(); 
  
      switch(i) { 
          default: 
              printf("\nHi..\n"); 
              break; 
          case 1: 
            printf("\n\na"); 
            break; 
          case 2: 
            printf("\nb\n"); 
            break; 
          case 3: 
              printf("\nc"); 
              break; 
      } 
}


 

Following which, I got this:

main.c:(.text+0x33): undefined reference to `clrscr' 
collect2: error: ld returned 1 exit status

Could anyone help me understand what it means?

Feb 22 in Others by Rahul
• 8,980 points
72 views

1 answer to this question.

0 votes

 The ld returned 1 exit status error is the consequence of your previous errors as in your example there is an earlier error - undefined reference to 'clrscr' - and this is the real one. The exit status error just signals that the linking step in the build process encountered some errors. Normally exit status 0 means success, and exit status > 0 means errors. Various tools may be running while creating a program as separate steps to create the final executable. In your case one of those tools is ld, which first reports the error it found (clrscr reference missing), and then it returns the exit status. Since the exit status is > 0, it means an error and is reported.

In many cases tools return as the exit status the number of errors they encountered. So if the old tool finds two errors, its exit status would be 2.

answered Feb 22 by Aditya
• 7,280 points

Related Questions In Others

0 votes
1 answer

can somebody explain me what does "passing by value" and "Passing by reference" mean in C#?

To answer your question, “passing by value” ...READ MORE

answered Feb 10 in Others by Rahul
• 8,980 points
17 views
0 votes
1 answer

What does enctype='multipart/form-data' mean?

When any POST request is made, then ...READ MORE

answered Feb 10 in Others by Rahul
• 8,980 points
57 views
0 votes
1 answer

What does it mean when owner is None on an AWS S3 object?

S3 Object Ownership is an Amazon S3 ...READ MORE

answered Mar 15 in Others by Edureka
• 8,820 points
104 views
+1 vote
1 answer

what is the difference between error and stderr in Node.js?

Error is an object created by Node.js to handle ...READ MORE

answered Jul 4, 2019 in Others by sunshine
• 1,280 points
1,027 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,060 points
177 views
0 votes
1 answer

setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,060 points
1,323 views
0 votes
1 answer

How to pass large records to map/reduce tasks?

Hadoop is not designed for records about ...READ MORE

answered Sep 25, 2018 in Big Data Hadoop by Frankie
• 9,830 points
765 views
0 votes
1 answer

Invalid method parameters for eth_sendTransaction

params needs to be an array, try {"jsonrpc":"2.0","method":"eth_se ...READ MORE

answered Sep 28, 2018 in Blockchain by digger
• 26,720 points
528 views
0 votes
1 answer

TCPDF ERROR: Some data has already been output, can't send PDF file

To answer your question, do add the ...READ MORE

answered Feb 16 in Others by Aditya
• 7,280 points
10 views
0 votes
1 answer

How does the "position: sticky;" property work?

Do check if an ancestor element has ...READ MORE

answered Feb 16 in Others by Aditya
• 7,280 points
12 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP