This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
how to compile and link embedded template class with g++
- From: robin <armrobin at 21cn dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 20 May 2005 04:42:05 +0800
- Subject: how to compile and link embedded template class with g++
- Reply-to: armrobin at 21cn dot com
Hi, all:
I arm using the libnurbs library in my project,
the libnurbs is a Nurbs spline project,
http://libnurbs.sourceforge.net
this project widely use the emdded template class as data type.
I just want to test the libnurbs with my below code:
--------------
/*
* file mynurbs.cpp
*/
#include <nurbs++/nurbs.h>
// testing of interpolation and approximation
using namespace PLib;
int main(void)
{
int i;
int deg = 3;
Vector_HPoint3Df P(10); // this is linking error sentenc
printf("Test nurbs++ !\n");
return 0;
}
----------------------
and compile the code with below command:
$ g++ -o mycurve mycurve.cpp
but some error was prompted to me:
-------------------------
/tmp/ccWEpvZI.o(.gnu.linkonce.t._ZN4PLib6VectorINS_9HPoint_nDIfLi3EEEED1Ev+0x16): In function `PLib::Vector<PLib::HPoint_nD<float, (int)3> >::~Vector [in-charge]()':
: undefined reference to `PLib::BasicArray<PLib::HPoint_nD<float,
(int)3> >::~BasicArray [not-in-charge]()'
/tmp/ccWEpvZI.o(.gnu.linkonce.r._ZTVN4PLib6VectorINS_9HPoint_nDIfLi3EEEEE+0x10): undefined reference to `PLib::BasicArray<PLib::HPoint_nD<float, (int)3> >::reset(PLib::HPoint_nD<float, (int)3>)'
/tmp/ccWEpvZI.o(.gnu.linkonce.t._ZN4PLib6VectorINS_9HPoint_nDIfLi3EEEEC1Ei+0x14): In function `PLib::Vector<PLib::HPoint_nD<float, (int)3> >::Vector[in-charge](int)':
: undefined reference to `PLib::BasicArray<PLib::HPoint_nD<float,
(int)3> >::BasicArray[not-in-charge](int)'
/tmp/ccWEpvZI.o(.gnu.linkonce.t._ZN4PLib6VectorINS_9HPoint_nDIfLi3EEEED0Ev+0x16): In function `PLib::Vector<PLib::HPoint_nD<float, (int)3> >::~Vector [in-charge deleting]()':
: undefined reference to `PLib::BasicArray<PLib::HPoint_nD<float,
(int)3> >::~BasicArray [not-in-charge]()'
collect2: ld returned 1 exit status
--------------
why? what should I do that in order to compiling and linking the
templated classes with g++?
thanks in advanced
Robin