public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* g++ deriving from a template class link error
       [not found] <978317671.3731.ezmlm@gcc.gnu.org>
@ 2000-12-31 19:09 ` Lawrence W. Leung
  0 siblings, 0 replies; only message in thread
From: Lawrence W. Leung @ 2000-12-31 19:09 UTC (permalink / raw)
  To: gcc-help

hi,

I ran into this strange link error when attempting to compile a program
with a simple class derived from a template class.  I have duplicated the
simple test program in two ways: 1. with everything in different files
2. with everything in one file.  #1 compiles, links and runs.  #2 compiles
but doesn't link.

Axes is the templated class and deriv is the derived class.


#2 returns this error:
[ricki@ll233 test]$ g++ -o out deriv.cpp axes.cpp
/tmp/cc82pCjC.o: In function `main':
/tmp/cc82pCjC.o(.text+0x10): undefined reference to `Axes<int>::Axes(int)'
/tmp/cc82pCjC.o(.text+0x7a): undefined reference to
`Axes<int>::~Axes(void)'
/tmp/cc82pCjC.o(.text+0xaa): undefined reference to
`Axes<int>::~Axes(void)'
/tmp/cc82pCjC.o: In function `deriv::deriv(void)':
/tmp/cc82pCjC.o(.deriv::gnu.linkonce.t.(void)+0x11): undefined reference
to `Axes<int>::Axes(int)'
/tmp/cc82pCjC.o(.deriv::gnu.linkonce.t.(void)+0x37): undefined reference
to `Axes<int>::~Axes(void)'
/tmp/cc82pCjC.o: In function `deriv::~deriv(void)':
/tmp/cc82pCjC.o(.gnu.linkonce.t._._5deriv+0x14): undefined reference to
`Axes<int>::~Axes(void)'
collect2: ld returned 1 exit status


In #1 all the stuff from #2 is condensed into a "test.cpp" file and
compiled with "g++ test.cpp".

I've included all the files I've used.  I'm using the compiler that came
with Mandrake 7.2 (g++ 2.95.3).

Any ideas?

Thanks
-Larry

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-31 19:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <978317671.3731.ezmlm@gcc.gnu.org>
2000-12-31 19:09 ` g++ deriving from a template class link error Lawrence W. Leung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).