Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ld errors

0 views
Skip to first unread message

Brendan Bond

unread,
Dec 20, 2003, 2:02:24 PM12/20/03
to
I just have a few questions about gcc's linker, ld: if I have multiple c++
files, (say "class.cc, class.h, and main.cc), and all #include directives
are in their proper places, is there anything I need to do besides "g++
main.cc"? With a container class that I made for a class assignment,
here's the linker output I got:
-----------------------------------
/tmp/ccP5jlPc.o(.text+0x19): In function `main':
: undefined reference to `mycontainer::mycontainer[in-charge]()'
/tmp/ccP5jlPc.o(.text+0x48): In function `main':
: undefined reference to `mycontainer::add(int)'
/tmp/ccP5jlPc.o(.text+0x73): In function `main':
: undefined reference to `mycontainer::~mycontainer [in-charge]()'
/tmp/ccP5jlPc.o(.text+0x8a): In function `main':
: undefined reference to `mycontainer::~mycontainer [in-charge]()'
collect2: ld returned 1 exit status
-----------------------------------
Thanks!

-Brendan Bond <bren...@austin.rr.com>

Paul Pluzhnikov

unread,
Dec 20, 2003, 2:10:46 PM12/20/03
to
Brendan Bond <bre...@austin.rr.com> writes:

> I just have a few questions about gcc's linker, ld: if I have multiple c++
> files, (say "class.cc, class.h, and main.cc), and all #include directives
> are in their proper places, is there anything I need to do besides "g++
> main.cc"?

Yes: "g++ main.cc class.cc"

> With a container class that I made for a class assignment,
> here's the linker output I got:
> -----------------------------------
> /tmp/ccP5jlPc.o(.text+0x19): In function `main':
> : undefined reference to `mycontainer::mycontainer[in-charge]()'

Naturally: since you didn't link in class.o, all of mycontainer
methods defined in class.cc came out unresolved.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

0 new messages