what does "collect2: ld returned 1 exit status" mean?

what does "collect2: ld returned 1 exit status" mean?

Post by Claus Busk Anderse » Sat, 30 Mar 2002 01:47:27



im trying to compile this:

void* ServeClient( void* socket )

{

HttpServer Server;

Server.ServeRequest(socket);

return(0);

Quote:}

with httpserver.h included in the top of the file. I get the following
errors

/home/can/tmp/ccCmU16R.o: In function `ServeClient(void *)':
/home/can/tmp/ccCmU16R.o(.text+0x1d4): undefined reference to
`HttpServer::HttpServer(void)'
/home/can/tmp/ccCmU16R.o(.text+0x1eb): undefined reference to
`HttpServer::ServeRequest(void *)'
/home/can/tmp/ccCmU16R.o(.text+0x1ff): undefined reference to
`HttpServer::~HttpServer(void)'
/home/can/tmp/ccCmU16R.o(.text+0x21d): undefined reference to
`HttpServer::~HttpServer(void)'
collect2: ld returned 1 exit status

Can anyone decode it so I can understand?

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Tobias Oe » Sat, 30 Mar 2002 01:50:27



> im trying to compile this:

> void* ServeClient( void* socket )

I wouldn't use socket as a variable name. There's a C function of that name.

Quote:

> {

> HttpServer Server;

> Server.ServeRequest(socket);

> return(0);

> }

> with httpserver.h included in the top of the file. I get the following
> errors

> /home/can/tmp/ccCmU16R.o: In function `ServeClient(void *)':
> /home/can/tmp/ccCmU16R.o(.text+0x1d4): undefined reference to
> `HttpServer::HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x1eb): undefined reference to
> `HttpServer::ServeRequest(void *)'
> /home/can/tmp/ccCmU16R.o(.text+0x1ff): undefined reference to
> `HttpServer::~HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x21d): undefined reference to
> `HttpServer::~HttpServer(void)'
> collect2: ld returned 1 exit status

> Can anyone decode it so I can understand?

You are calling functions for which the linker can't find the code. You
need to let the linker know which libraries to search in with a -lliname
switch. (The header you include only has the definitions=prototypes, not
the actual code)

Tobias.

--
unix http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.programmer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by John Gordon,217-352-6511x7418,CEERD-CF- » Sat, 30 Mar 2002 01:53:57



Quote:> im trying to compile this:
> void* ServeClient( void* socket )
> {
> HttpServer Server;
> Server.ServeRequest(socket);
> return(0);
> }
> with httpserver.h included in the top of the file. I get the following
> errors

as someone once explained it to me, header files are like the
instruction manual that came with your new washing machine.  the manual
tells you how to use the washer, but the manual by itself won't wash
any clothes.

in other words:

just including the header file isn't good enough.  you also need to
link the appropriate library.

Quote:> /home/can/tmp/ccCmU16R.o: In function `ServeClient(void *)':
> /home/can/tmp/ccCmU16R.o(.text+0x1d4): undefined reference to
> `HttpServer::HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x1eb): undefined reference to
> `HttpServer::ServeRequest(void *)'
> /home/can/tmp/ccCmU16R.o(.text+0x1ff): undefined reference to
> `HttpServer::~HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x21d): undefined reference to
> `HttpServer::~HttpServer(void)'
> collect2: ld returned 1 exit status
> Can anyone decode it so I can understand?

it's telling you that it doesn't know about the HttpServer() method.

---
John Gordon                  "No Silicon Heaven?  Preposterous!  Where would

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Claus Busk Anderse » Sat, 30 Mar 2002 02:27:25


thanks folks - I learn every day



Quote:> im trying to compile this:

> void* ServeClient( void* socket )

> {

> HttpServer Server;

> Server.ServeRequest(socket);

> return(0);

> }

> with httpserver.h included in the top of the file. I get the following
> errors

> /home/can/tmp/ccCmU16R.o: In function `ServeClient(void *)':
> /home/can/tmp/ccCmU16R.o(.text+0x1d4): undefined reference to
> `HttpServer::HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x1eb): undefined reference to
> `HttpServer::ServeRequest(void *)'
> /home/can/tmp/ccCmU16R.o(.text+0x1ff): undefined reference to
> `HttpServer::~HttpServer(void)'
> /home/can/tmp/ccCmU16R.o(.text+0x21d): undefined reference to
> `HttpServer::~HttpServer(void)'
> collect2: ld returned 1 exit status

> Can anyone decode it so I can understand?

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Joe Durusa » Sat, 30 Mar 2002 05:32:10




> > im trying to compile this:

> > void* ServeClient( void* socket )
> > {
> > HttpServer Server;
> > Server.ServeRequest(socket);
> > return(0);
> > }

> > with httpserver.h included in the top of the file. I get the following
> > errors

> as someone once explained it to me, header files are like the
> instruction manual that came with your new washing machine.  the manual
> tells you how to use the washer, but the manual by itself won't wash
> any clothes.

> in other words:

> just including the header file isn't good enough.  you also need to
> link the appropriate library.

> > /home/can/tmp/ccCmU16R.o: In function `ServeClient(void *)':
> > /home/can/tmp/ccCmU16R.o(.text+0x1d4): undefined reference to
> > `HttpServer::HttpServer(void)'
> > /home/can/tmp/ccCmU16R.o(.text+0x1eb): undefined reference to
> > `HttpServer::ServeRequest(void *)'
> > /home/can/tmp/ccCmU16R.o(.text+0x1ff): undefined reference to
> > `HttpServer::~HttpServer(void)'
> > /home/can/tmp/ccCmU16R.o(.text+0x21d): undefined reference to
> > `HttpServer::~HttpServer(void)'
> > collect2: ld returned 1 exit status

> > Can anyone decode it so I can understand?

> it's telling you that it doesn't know about the HttpServer() method.

> ---
> John Gordon                  "No Silicon Heaven?  Preposterous!  Where would


To the O.P.: If you are using a unix-like system, you might find the
required libs in the man pages for the functions in question, or you
could
use nm to search out the stuff you need.  Unfortunately, my system
has nothing like this in it.  One other possibility: if you are using
c++ code, make sure that you use a c++ compiler.  Don't use gcc to link
c++ code, it won't work.

Speaking only for myself,

Joe Durusau

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Terran Melconi » Sat, 30 Mar 2002 07:55:31




Quote:>c++ code, make sure that you use a c++ compiler.  Don't use gcc to link
>c++ code, it won't work.

Are you sure?  I've done it often in the past, and I thought the only
difference was that it didn't automatically include libstdc++ like it
did when invoked as g++.

Here's what the documentation says:

    `g++' is a program that calls GCC with the default language set
    to C++, and automatically specifies linking against the C++ library.

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Erik Max Franci » Sat, 30 Mar 2002 09:29:23



> Are you sure?  I've done it often in the past, and I thought the only
> difference was that it didn't automatically include libstdc++ like it
> did when invoked as g++.

You're correct; gcc determines automatically what language to compile by
the file extension, and can be overridden with the -x option.  g++ links
in the proper C++ libraries so you don't have to do it manually.

Compiling a C++ module with gcc -c, for instance, is perfectly
legitimate.

--

 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Laws are silent in time of war.
\__/ Cicero
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.

 
 
 

what does "collect2: ld returned 1 exit status" mean?

Post by Joe Durusa » Wed, 03 Apr 2002 05:48:02





> >c++ code, make sure that you use a c++ compiler.  Don't use gcc to link
> >c++ code, it won't work.

> Are you sure?  I've done it often in the past, and I thought the only
> difference was that it didn't automatically include libstdc++ like it
> did when invoked as g++.

> Here's what the documentation says:

>     `g++' is a program that calls GCC with the default language set
>     to C++, and automatically specifies linking against the C++ library.

It links in other stuff as well, at least on most unix-like systems.
The Solaris ng, for example, is filled with examples of people
complaining about linker errors caused by this sort of thing.  You
can, of course, _compile_ with either one then link witht he right
one, or even call ld directly, but it can get messy.

Speaking only for myself,

Joe Durusau

 
 
 

1. Bad value collect2: ld returned 1 exit status

Hello,

I post this message as a hint for all the people complaining about
this error

Bad value collect2: ld returned 1 exit status

and never got any answer (you can see LOTS of 1-message threads). I
also had it, it comes alone, no other complaint about headers or TOC
or symbols or whatever. -Wall or anything show no errors at all, ld
just fails and that's it.

My situation was: I copied by mistake on that Linux machine a Solaris
library ld used later for linking... so I would still call that a
problem of the linker which was obviously unable to figure out its
about another platform binary file, or at least give an understandable
error message. So guys check all your libraries to see if they are
really what they are supposed to be.

Best regards,
S

2. initialize 2 cards through one module

3. Does select return "read ready" or "won't block" status?

4. Converting to SCSI Questions

5. trap "action; exit" signals = trap "action" exit?

6. RedHat5.0 and network PCard

7. What is this supposed to return: "trap 'exit ' 0; exit"?

8. Ide.c and Flash drives

9. GETSERVBYNAME()????????????????????"""""""""""""

10. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

11. Change "return EBLAH" to "return -EBLAH in drivers/*

12. GNU "as" and "ld" not supported for X 4.0 build?