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, 2022 in Others by Rahul
• 9,680 points
33,110 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, 2022 by Aditya
• 7,660 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, 2022 in Others by Rahul
• 9,680 points
232 views
0 votes
1 answer

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

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

answered Feb 10, 2022 in Others by Rahul
• 9,680 points
500 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, 2022 in Others by gaurav
• 22,940 points
553 views
0 votes
0 answers

What does "int 21h" mean in Assembly?

What does the command int 21h mean?  For example: mov ...READ MORE

May 24, 2022 in Others by Kichu
• 19,040 points
123 views
0 votes
1 answer

Function default argument value depending on argument name in C++ [duplicate]

When the function is called with no argument for the corresponding parameter, the default argument is evaluated.  In a default argument, a parameter must not appear as a potentially evaluated expression.  A function's parameters declared before a default argument are in scope and can obscure the namespace and class member name. It provides the following example: int h(int a, ...READ MORE

answered Jun 7, 2022 in C++ by Damon
• 4,960 points
99 views
0 votes
1 answer

C++ string in classes

The std namespace contains the string class. You need change the class to something like this: class Language { public: ...READ MORE

answered Jun 15, 2022 in C++ by Damon
• 4,960 points
288 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,100 points
263 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,100 points
1,573 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, 2022 in Others by Aditya
• 7,660 points
949 views
0 votes
1 answer

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

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

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