www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/03/16/06:13:52

From: thon AT irp DOT uni-stuttgart DOT de (andreas thon)
Subject: Re: Does DJGPP support C++ templates?
To: nfluhr1 AT gl DOT umbc DOT edu (Neil L. Fluhr ; BS CMSC)
Date: Thu, 16 Mar 1995 11:08:38 +0100 (MET)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> 
> I am trying to use a List template class and I keep getting:
> 
>    "undefined reference List<int>::Insert()"
>    "undefined reference List<int>::First()"
> 
>     ...and so on for every List function that is called in my client
>        program. 
> 
> I am using my own list implementation (not the one included with DJGPP). I 
> have my List template class declaration in my header file (list.h) and the
> implementation in my list.cc file. My client program is in its separate  
> file (intlist.cc).
> 
> I have tried the -v switch and the above output only occurs after the linker
> is called.
> 
> Any ideas? Please send responses to my e-mail address <nfluhr1 AT gl DOT umbc DOT edu>
> as I do not subscribe to the mailing list.
> 
> Thanks in advance!
> Neil
> 

I've got the same problem. When you compile the list.cc file, the compiler
doesn't know, that you want to use integers in intlist.cc for the templates.
Therefore the Linker returns an undefined reference to the List<int>
functions. If you have the definitions together with the declaration in 
the header file, the program will work. But there should be another
compiler specific solution to this problem, which I haven't found yet.
Any help would be appreciated.

Andreas  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019