Hello,
I have a problem with auto-loading (root 6.12/06) the library when the templated class it contains is instantiated, while the auto-loading works fine when instantiating other classes from the same library.
The templated class looks like
namespace o2 {namespace ITSMFT {
template <class Mapping = o2::ITSMFT::ChipMappingITS>
class RawPixelReader : public PixelReader {
//...
private:
Mapping mMapping;
ClassDefOverride(RawPixelReader, 1);
};
}}
and in the LinkDef I require two specializations (together with classes which are used as template arguments):
#pragma link C++ class o2::ITSMFT::RawPixelReader < o2::ITSMFT::ChipMappingITS > +;
#pragma link C++ class o2::ITSMFT::RawPixelReader < o2::ITSMFT::ChipMappingMFT > +;
#pragma link C++ class o2::ITSMFT::ChipMappingITS + ;
#pragma link C++ class o2::ITSMFT::ChipMappingMFT + ;
Everything works fine, the template specializations are fully functional, except that if I try to instantiate them, the interpreter does not find correct library:
root [0] o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> vv
ROOT_prompt_0:1:13: error: no member named 'RawPixelReader' in namespace 'o2::ITSMFT'
o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> vv
~~~~~~~~~~~~^
Warning in <TInterpreter::LoadLibraryMap>: Problems in /home/shahoian/alice/sw/ubuntu1604_x86-64/O2/dev_PixRead-1/lib/libITSMFTReconstruction.rootmap declaring '
#line 1 "Forward declarations from /home/shahoian/alice/sw/ubuntu1604_x86-64/O2/dev_PixRead-1/lib/libITSMFTReconstruction.rootmap"
namespace o2 { namespace ITSMFT { } }namespace std { }namespace o2 { namespace ITSMFT { class ChipMappingMFT; } }namespace o2 { namespace ITSMFT { class ChipMappingITS; } }' were encountered.
The object is created w/o problem if I load in advance the corresponding library:
root [0] gSystem->Load("libITSMFTReconstruction");
root [1] o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> vv
(o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> &) @0x7fcafd71c020
root [2]
The dictionary and the rootmap generation proceeds w/o problem, with rootcint -v4 I see that the template is recognized and its arguments are added to the { decls }
block:
o o2::ITSMFT::PixelReader --> , payloadCode
o o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> --> , payloadCode
o o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingMFT> --> , payloadCode
o o2::ITSMFT::TopologyFastSimulation --> , payloadCode
Class RawPixelReader is a template specialisation. Treating its arguments.
o Template argument successfully treated. Arg fwd decl:
namespace o2 { namespace ITSMFT { class ChipMappingMFT; } }
Class RawPixelReader is a template specialisation. Treating its arguments.
o Template argument successfully treated. Arg fwd decl:
namespace o2 { namespace ITSMFT { class ChipMappingITS; } }
Info: Rootmap file name ./libITSMFTReconstruction.rootmap and lib name(s) "ITSMFTReconstruction.so"
but the template forward declaration itslef is not appearing in the rootmap, which looks like (edited to not show irrelevant classes)
{ decls }
namespace o2 { namespace ITSMFT { } }
namespace std { }
namespace o2 { namespace ITSMFT { class ChipMappingMFT; } }
namespace o2 { namespace ITSMFT { class ChipMappingITS; } }
[ ITSMFTReconstruction.so ]
# List of selected classes
...
class o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS>
class o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingMFT>
header ITSMFTReconstruction/ChipMappingITS.h
If I modify by hand the { decls }
block of libITSMFTReconstruction.rootmap
, adding the template forward declaration as
{ decls }
namespace o2 { namespace ITSMFT { } }
namespace std { }
namespace o2 { namespace ITSMFT { class ChipMappingMFT; } }
namespace o2 { namespace ITSMFT { class ChipMappingITS; } }
namespace o2 { namespace ITSMFT { template <class Mapping> class RawPixelReader; } }
then the auto-loading works w/o problem:
root [0] o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> vv
(o2::ITSMFT::RawPixelReader<o2::ITSMFT::ChipMappingITS> &) @0x7f40c689f020
Any hint why the template is not forward declared in the rootmap? We have plenty of templates in other libraries, and for them the forward declaration works fine.
Best regards,
Ruben