I know this indicates a linker problem, mostly unresolved symbols. I know that to resolve that problem / to get rid of that errormessage, one would have to provide much more information. I know there is a lot of questions on resolving this problems on SO already.
My questions aims at helping to understand make and ld, to find out what (and who) is trying to express what with this line.
collect2: ld returned 1 exit status
- What does “collect2:” mean? Is it a step make invokes ? I can’t find an executable with that name on my system.
- Does it mean I am using ld ? I configured my project / Makefile so that g++ should do the linking, so why is LD still involved
- Who is writing that message ? make ? ld ? g++ ?
- Is there a meaningful list of possible exit codes ?
First things first, you need to know that the command-line programs named
gccandg++are only umbrella (wrappers) around the actual preprocessor/parser-compiler/assembler/linker commands. Their real name iscpp,cc1orcc1plus,asandld, respectively. GCC helps in unifying their use, command line interface and providing a meaningful set of default (and required) options for them. It is very hard, for example, to link a binary directly usingld– ifldis not run with all the 20+ (IIRC) correct options, it just fails to work.Now that you know that, you can see:
It rather means you invoke GCC but in turn it invokes LD. GCC itself knows nothing – neither compiling, neither linking, as it’s just a wrapper. (Go do a
wc -con/usr/bin/gccand be surprised that it’s only a few kilobytes! Now do the same for/usr/libexec/gcc/cc1plusand find out the horrifying truth: it is several 10 megs big!)Collect2 is also another level of indirection between gcc and ld. More about it on its official website.
Either g++ (that’s it as far as I know) or
collect2itself maybe.The meaning is conventional – zero means success, nonzero means failure. If an exhaustive list exists, it should be able to be viewed by invoking
man ld.