[LC++]How to link

Ezra Taylor ezratay1 at netzero.net
Wed Aug 29 04:37:04 UTC 2001


Hello Laszlo:

Try:     g++ -c My.cpp My.h
then     g++ -o caller caller.cpp My.o


Laszlo Boszormenyi wrote:

> Hi!
>
> I have these files, but I can not link them together. What I do:
> g++ -c My.cpp
> g++ -c caller.cpp
> g++ My.o caller.o -o caller
>
> I get:
> caller.o: In function `main':
> caller.o(.text+0xe): undefined reference to `My::My(void)'
> caller.o(.text+0x6f): undefined reference to `My::~My(void)'
> caller.o(.text+0x9a): undefined reference to `My::~My(void)'
> collect2: ld returned 1 exit status
>
> My g++ version is 2.95.4. Thanks in advance, Laszlo
>
>   ------------------------------------------------------------------------
>                  Name: caller.cpp
>    caller.cpp    Type: Plain Text (TEXT/PLAIN)
>              Encoding: BASE64
>
>              Name: My.cpp
>    My.cpp    Type: Plain Text (TEXT/PLAIN)
>          Encoding: BASE64
>
>            Name: My.h
>    My.h    Type: Plain Text (TEXT/PLAIN)
>        Encoding: BASE64

----------------------------------------------------
NetZero Platinum
Sign Up Today - Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97



More information about the tuxCPProgramming mailing list