> Error: link requested for unknown class WeightedLink G__auto6316LinkDef.h
This message indicates that you have not passed a hand coded linkdef file to
rootcint
and that rootcint is creating one automatically (G__auto6316LinkDef.h) that
request
the linking of a class whose name is the name of the header file. So I
assume that
you command line is:
rootcint -f mydict.cxx -c WeightedLink.h
and you should update it to be
rootcint -f mydict.cxx -c WeightedLink.h myLinkDef.h
Cheers,
Philippe.
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
Behalf Of Marc de Kamps
Sent: Monday, August 18, 2008 5:28 AM
To: roottalk_at_lxbuild091.cern.ch
Subject: [ROOT] Problem writing templated class to file
Hi,
I can successfully write objects of type WeightedLink to file ina program and read them out again in a CINT session.
I then try to make WeightedLink templated and adapt the LinkDef.h file accordingly. rootcint then stops with an error message:
Error: link requested for unknown class WeightedLink G__auto6316LinkDef.h
As you can see, the class has a default constructor. It is my understanding that putting the following statement in the LinkDef.h should make ROOT aware of the double version of the template code, but apparently it doesn't. Any suggestions as to what might be wrong?
#pragma link C++ class WeightedLink<double>+;
Thanks,
Marc
The original WeightedLink.h is:
class WeightedLink : public TNamed
{
public:
ClassDef(WeightedLink,1);
Id _id_from;
Id _id_to;
double _weight;
WeightedLink():_id_from(Id(0)),_id_to(Id(0)),_weight(0.0){}
WeightedLink
(
Id id_from, Id id_to, double weight ):
_id_from(id_from),
_id_to(id_to),
_weight(weight)
{ } }; typedef WeightedLink D_WeightedLink;
It is changed into:
template <class Weight>
class WeightedLink : public TNamed
{
public:
ClassDef(WeightedLink,1);
Id _id_from;
Id _id_to;
double _weight;
WeightedLink():_id_from(Id(0)),_id_to(Id(0)),_weight(0.0){}
WeightedLink
(
Id id_from, Id id_to, double weight ):
_id_from(id_from),
_id_to(id_to),
_weight(weight)
{ } }; typedef WeightedLink<double> D_WeightedLink;
The relevant entry in LinkDef.h is changed from
#pragma link C++ class WeightedLink<+;
into
#pragma link C++ class WeightedLink<double>+;
-
Dr. Marc de Kamps
Biosystems Group
School of Computing
University of Leeds
LS29JT, Leeds, UK
<mailto:dekamps_at_comp.leeds.ac.uk> dekamps_at_comp.leeds.ac.uk
http:/www.comp.leeds.ac.uk/dekamps Received on Mon Aug 18 2008 - 22:02:59 CEST
This archive was generated by hypermail 2.2.0 : Mon Aug 18 2008 - 23:50:01 CEST