c - What does collect2: error: ld returned 1 exit status mean

c – What does collect2: error: ld returned 1 exit status mean?

c – What does collect2: error: ld returned 1 exit status mean?

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, 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 ld tool finds two errors, its exit status would be 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

c – What does collect2: error: ld returned 1 exit status mean?

clrscr is not standard C function. According to internet, it used to be a thing in old Borland C.
Is clrscr(); a function in C++?

Related posts on C++  :

Leave a Reply

Your email address will not be published.