This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

how to compile and link embedded template class with g++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]