A
aaragon
Hi everyone,
I have a linking error when using gcc4.2 and static member variables.
The class template definition is something around the following:
template<>
class Element<L2_t> : public Element_common<L2, Side<2,2> > {
public:
static const ubyte_t dim_ = 2;
static const ubyte_t num_nodes_ = 2;
static const ubyte_t gauss_pts_= 3;
// member functions
};
Undefined symbols:
"fea::Element<(fea::Element_type)1>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE1EE10gauss_pts_E
$non_lazy_ptr in element.o
"fea::Element<(fea::Element_type)2>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE2EE10gauss_pts_E
$non_lazy_ptr in element.o
"fea::Element<(fea::Element_type)3>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE3EE10gauss_pts_E
$non_lazy_ptr in element.o
ld: symbol(s) not found
The strange thing is that I have many other static variables with the
same kind of definition (same type and const as you can see) but it
only complaints about the gauss_pts_ member variable. I solved the
problem by moving the definition to the cpp file as follows:
// in cpp file
const ubyte_t Element<L2_t>::gauss_pts_ = 3;
But I want to understand really what is happening here. When I compile
the code with gcc4.3, the problem disappears. So, is this a bug in the
compiler?
Thanks for the help,
aa
I have a linking error when using gcc4.2 and static member variables.
The class template definition is something around the following:
template<>
class Element<L2_t> : public Element_common<L2, Side<2,2> > {
public:
static const ubyte_t dim_ = 2;
static const ubyte_t num_nodes_ = 2;
static const ubyte_t gauss_pts_= 3;
// member functions
};
Undefined symbols:
"fea::Element<(fea::Element_type)1>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE1EE10gauss_pts_E
$non_lazy_ptr in element.o
"fea::Element<(fea::Element_type)2>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE2EE10gauss_pts_E
$non_lazy_ptr in element.o
"fea::Element<(fea::Element_type)3>::gauss_pts_", referenced from:
__ZN3fea7ElementILNS_12Element_typeE3EE10gauss_pts_E
$non_lazy_ptr in element.o
ld: symbol(s) not found
The strange thing is that I have many other static variables with the
same kind of definition (same type and const as you can see) but it
only complaints about the gauss_pts_ member variable. I solved the
problem by moving the definition to the cpp file as follows:
// in cpp file
const ubyte_t Element<L2_t>::gauss_pts_ = 3;
But I want to understand really what is happening here. When I compile
the code with gcc4.3, the problem disappears. So, is this a bug in the
compiler?
Thanks for the help,
aa