Help with templates

Ricardo Santos rs@isctem.com
Thu Aug 12 23:04:00 GMT 2004


I have a problem with templates.

I am doing a little class (Stack) to demonstrate templates, and I have a 
library problem.

I don't know wich library I have to compile with, to use templates...

My compilation line is:

g++ -o s StackAr.cpp mStackAr.cpp


And the Result of that command is:

/home/rs/tmp/cc0KjPdZ.o(.text+0x1c): In function `main':
: undefined reference to `StackAr<int>::StackAr[in-charge]()'
/home/rs/tmp/cc0KjPdZ.o(.text+0x36): In function `main':
: undefined reference to `StackAr<int>::Push(int const&)'
/home/rs/tmp/cc0KjPdZ.o(.text+0x50): In function `main':
: undefined reference to `StackAr<int>::Push(int const&)'
/home/rs/tmp/cc0KjPdZ.o(.text+0x6a): In function `main':
: undefined reference to `StackAr<int>::Push(int const&)'
/home/rs/tmp/cc0KjPdZ.o(.text+0x84): In function `main':
: undefined reference to `StackAr<int>::Pop()'
/home/rs/tmp/cc0KjPdZ.o(.text+0xb6): In function `main':
: undefined reference to `StackAr<int>::Top() const'
/home/rs/tmp/cc0KjPdZ.o(.text+0xe8): In function `main':
: undefined reference to `StackAr<int>::Pop()'
/home/rs/tmp/cc0KjPdZ.o(.text+0x10f): In function `main':
: undefined reference to `StackAr<int>::~StackAr [in-charge]()'
/home/rs/tmp/cc0KjPdZ.o(.text+0x12d): In function `main':
: undefined reference to `StackAr<int>::~StackAr [in-charge]()'
collect2: ld returned 1 exit status

I am using Mandrake Linux in x86.

Thanks

Ricardo



More information about the Gcc-help mailing list