Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1012 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does "collect2: error: ld returned 1 exit status" mean?

#1
I see the error *collect2: error: ld returned 1 exit status* very often. For example, I was trying to build the following snippet of code:

```lang-c
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;
}
}
```

And I got this:

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

What does it mean?

Reply

#2
In your situation you got a reference to the missing symbols. But in some situations, ld will not provide error information.

If you want to expand the information provided by ld, just add the following parameters to your $(LDFLAGS)

-Wl,-V
Reply

#3
Include: `#include<stdlib.h>`

and use `System("cls")` instead of `clrscr()`
Reply

#4
Just press Ctrl+S then do the execution part
Reply

#5
`clrscr` is not standard C function. According to the Internet, it used to be a thing in old [C++Builder][1].

*https://stackoverflow.com/questions/930138/is-clrscr-a-function-in-c*


[1]:

[To see links please register here]


Reply

#6
The `ld returned 1 exit status` error is the consequence of previous errors. 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.

When you build your program, multiple tools may be run as separate steps to create the final executable. In your case, one of those tools is [ld][1], 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 the number of errors they encountered as the exit status. So if the **ld** tool finds two errors, its exit status would be 2.

[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through