Mail Archives: djgpp/1998/09/05/11:16:22
Jorge Bruno S. S. Morgado wrote:
> template<class T>
> class matrix
> {
> gxx -c -o math.o math.cc
> gxx -c -o main.o main.cc
> gxx -o test.exe main.o math.o
>
> but this simply doesent work, it gives me lots of errors like:
> function <double> determinant(void) in class matrix not defined, and
> things like that.
> I've also noticed that the file math.o is very smal (only 375 bytes),
> and that, if I put the all class in the file math.h, and just include
> it from main.cc, it all goes fine, but this way, every time I make a
> change in another included file, I have to recompile all of it again.
>
> Also, when I do something like this (using varios pre-compiled files)
> with C (not C++) it works just fine.
>
> Is this a bug with gxx ?
> Why does this happens ?
I think it has to do with the way templates are handled. math.o is small
because there is (effectively) nothing in it. Templates are only compiled
when a reference to them if found. No references are found in math.cc. I
don't think the linker will link templated functions that had no instances
during compilation.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlis AT nbnet DOT nb DOT ca
- Raw text -