cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/22/05:52:46

Message-ID: <34263F31.433CE30B@cs.curtin.edu.au>
Date: Mon, 22 Sep 1997 17:49:38 +0800
From: Gordon German <gordon AT cs DOT curtin DOT edu DOT au>
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: template problems

I am a new user to DJGPP V2/RHIDE and am experiencing problems using
template classes in my code. I've checked through the FAQ and followed
the advice there, but so far, no success :-(
So, hopefully you guys can help :-)

Firstly, (following the advice from the FAQ), here are my environmental
parameters:

TMP=C:\WINDOWS\TEMP
winbootdir=C:\WINDOWS
COMSPEC=C:\WINDOWS\COMMAND.COM
PROMPT=$p$g
DJGPP=C:\DJGPP\DJGPP.ENV
PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\DOS;C:\DJGPP\BIN
TEMP=C:\DOS
windir=C:\WINDOWS
BLASTER=A220 I5 D1 H5 P330 T6

and my output from runnning go32-v2:

go32/v2 version 2.0 built Aug 12 1996 22:27:23
Usage: go32 coff-image [args]
Rename this to go32.exe only if you need a go32 that can run v2 binaries

as
 well as v1 binaries (old makefiles).  Put ahead of the old go32 in your

PATH
 but do not delete your old go32 - leave it in the PATH after this one.
Set GO32_V2_DEBUG=y in the environment to get verbose output.

DPMI memory available: 18683 Kb
DPMI swap space available: 11165 Kb

Now for my problem. I originally had one large header file, matrix.h,
which contained both the declarations and definitions for my template
classes Vector, Matrix2d and unique_list (along with a few other
non-template classes). On my UNIX box at work, this is included in my
main files with:

#ifndef __MATRIX_H
    #include "matrix.h"
#endif

with __MATRIX_H being defined in the matrix.h file. This works fine, no
compilation problems under g++ on IRIX 5.3.

After installing DJGPP V2 and RHIDE on my PC at home, I imported the
source files and tried a compile/link. I got errors:

"Error: Undefined reference to Vector<double>:: **** "

where **** is every member function/variable of the class Vector, for
every occurence in every file of my project. No lines in matrix.h that
were not associated with a template class created any errors.

I tried the following steps (in order):

1. Split the file matrix.h into two files matrix.h and matrix.cc, for
the declarations and implimentations respectively.

2. Added the libraries libgpp, libstdcx and libm to the libraries list
in RHIDE, in that order.

3. Added the switch cxx to the compiler

None of these changed anything - same number of errors.

Any ideas?

Many thanks,

        Gordon German

PS. I have since tried a small test program which calls the
implimentation file:

    #include "matrix.cc"

and matrix.cc includes matrix.h. This actually works, no errors. This
trick doesn't seem to work for multi-file projects, however. You either
get a "multiple define" error (if you include matrix.cc with each file -
even if you use the #ifndef syntax above!) or the same "Undefined
reference to Vector<double>:: **** " as before (if you only #include
matrix.cc in one file and matrix.h in the rest).

(gordon AT cs DOT curtin DOT edu DOT au)

- Raw text -


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