Using templates with g++

Using templates with g++

Post by FRANCIS GUIMO » Sun, 26 Mar 1995 06:43:57



Hi all,

    I'm having trouble using a library with templates in it.
Everything seems to be working fine when I compile the library,
but when I try to include it in an other file, the compiler says
that all the function are not in the .o file.  What am I doing
wrong?

I've read some stuff about the #pragma implementation and the
#pragma interface statements, but it's not very clear how to use it.

My librairie contains two file: dbllist.cc and dbllist.h and the file
that uses the librairie includes "dbllist.h".  Can it be the problem?
If so, in wich file should my librairie be, and how do I compile it and
include it?

By the way, I use GCC 2.5.8 on a Linux machine, but I have the same
problem when I try to compile on a SUN running SUN/OS 5.

Here is the output that I have when I compile (it is from the SUN):

$: g++ -o dbllist.o -c dbllist.cc
$: g++ exp_list.cc dbllist.o
Undefined                       first referenced
 symbol                             in file
addAtHead__t11DblLinkList1ZiPi      /tmp/cca000hF1.o
removeHead__t11DblLinkList1ZUc      dbllist.o
display__t11DblLinkList1Zi          /tmp/cca000hF1.o
addAfterCurrent__t11DblLinkList1ZiPi /tmp/cca000hF1.o
__pp__t11DblLinkList1Zii            /tmp/cca000hF1.o
flush__t11DblLinkList1Zi            /tmp/cca000hF1.o
addAtTail__t11DblLinkList1ZiPi      /tmp/cca000hF1.o
removeCurrent__t11DblLinkList1Zi    dbllist.o
removeFromHead__t11DblLinkList1ZiPi /tmp/cca000hF1.o
removeHead__t11DblLinkList1Zi       /tmp/cca000hF1.o
removeFromTail__t11DblLinkList1ZiPi /tmp/cca000hF1.o
addAfter__t11DblLinkList1ZiPiT1     /tmp/cca000hF1.o
removeCurrent__t11DblLinkList1ZUc   dbllist.o
__pp__t11DblLinkList1Zi             /tmp/cca000hF1.o
__pp__t11DblLinkList1ZUci           dbllist.o
ld: fatal: Symbol referencing errors. No output written to a.out

Any help would be appreciated

Francis Guimond

 
 
 

Using templates with g++

Post by Brandon Van eve » Mon, 27 Mar 1995 03:55:59



>Hi all,
>    I'm having trouble using a library with templates in it.
>Everything seems to be working fine when I compile the library,
>but when I try to include it in an other file, the compiler says
>that all the function are not in the .o file.  What am I doing
>wrong?

It's not you, it's GCC's handling of templates.  GCC's handling of
templates is relatively new, immature code.  Basically, it's bugged.
Get the .info docs from the GCC 2.6.3 source distribution.  There's a
section in there about template problems and what to do about them.

You could also get the gnu.g++ FAQ, which has some template problem
info as well.  Much quicker than downloading the 2.6.3 sources over a
modem.  :-)

Cheers,
Brandon

--
Brandon J. Van Every        |
Computer Graphics Guy       |    [This space intentionally left blank.]
C++  UNIX  X-Windows  Motif |