Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does collect2.exe do?

Tags:

c++

c

gcc

linker

ld

When I examine the code generated by gcc -v -o proggy.exe proggy.o I find that the command line expands into a large bunch of library options and libraries, all of which are linked using collect2.exe. What happened to ld.exe? Why don't I see that? Can someone explain to me what collect2.exe does?

like image 779
allynm Avatar asked May 12 '10 20:05

allynm


People also ask

What does collect2 do?

collect2 is a utility to arrange calling of initialisation functions at start time. It links the program and looks for these functions, creating a table of them in a temporary . c file, and then links the program a second time but including the new file. ld is called from collect2 at the end of this process.

How do I fix collect2 exe error?

The collect2 error is easily fixed by shutting down a program that is running in the background. Web developers usually face this problem once working with Dev C++ and other files.

What does collect2 error ld returned 1 exit status mean?

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.


2 Answers

collect2 is a utility used to generate a table of constructors that __main (an auto-generated function called at the beginning of main) depends on. Normally you don't see it because it's named ld on the file system, and it in turn calls the real ld (typically called real-ld, although collect2 will check a number of places looking for it)

like image 83
Michael Mrozek Avatar answered Sep 22 '22 16:09

Michael Mrozek


GCC uses a utility called collect2 on nearly all systems to arrange to call various initialization functions at start time. [link]

like image 36
Kirill V. Lyadvinsky Avatar answered Sep 24 '22 16:09

Kirill V. Lyadvinsky