Date: Fri, 17 Mar 1995 08:00:09 +0100 (CET) From: Roland Exler Sender: k3a0270 AT pop DOT uni-linz DOT ac DOT at Reply-To: R DOT Exler AT jk DOT uni-linz DOT ac DOT at To: djgpp Subject: RE: Does DJGPP support C++ templates? As I see, more people got the problem with templates I solved a few weeks ago, so I'll post it here: Problem: > I am trying to use a List template class and I keep getting: > > "undefined reference List::Insert()" > "undefined reference List::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). Explanation / Solution: If you compile list.cc, gcc can't know what type of instantiation you may be need in future, so list.o doesn't hold the code for List you need. To do this add a line template class List; to your file list.cc. This creates the code needed in list.o. See chapter 7.5 in the gcc-manual! I'm going the way described at Page 165, Point 3 and build a template-library of all my template-classes ever needed. Hope this helps, Roland +---------------------------------------+---------------------------+ I Roland Exler I EMAIL: I I Universitaet Linz I R DOT Exler AT jk DOT uni-linz DOT ac DOT at I I Institut fuer Elektrische Messtechnik I I I Altenbergerstr. 69 I Phone: I I A-4040 Linz, AUSTRIA I + 43 732 2468 9205 I +---------------------------------------+---------------------------+