Template class dlopen error

Hi,

I have ROOT 5.16/00 installed on OSX 10.4.11. I’m trying to write a general utility class to run in CINT which will plot arbitrary rows or columns from a text file as a chosen TGraph variant. I want to do this using a template class i.e. TTextToGraph<TGraphVariant>. I have a helper class which converts the text file into arrays of doubles (TTextToVector), which I’ve tested and works fine as a dynamic library loaded into CINT with “.L libTTextToVector.dylib” .

Okay, now on to the problem. I’ve managed to get TTextToGraph to compile and made a dylib but when I try to load it into CINT I get the following error:

[quote]dlopen error: dlopen(/Users/hughdickinson/Documents/Work/Programs/TTextToGraph/./libTTextToGraph.dylib, 9): Symbol not found: __ZN12TTextToGraphI6TGraphED0Ev
Referenced from: /Users/hughdickinson/Documents/Work/Programs/TTextToGraph/./libTTextToGraph.dylib
Expected in: dynamic lookup

Load Error: Failed to load Dynamic link library /Users/hughdickinson/Documents/Work/Programs/TTextToGraph/./libTTextToGraph.dylib[/quote]

I’ve attached the source files for TTextToGraph and TTextToVector and the two linkDef files. Any help with this problem would be much appreciated. Maybe a class already exists to do what I’m trying to achieve?

Cheers,

Hugh Dickinson
LinkDef.h (156 Bytes)
TTextToVector.h (1.85 KB)
TTextToVector.cxx (5.54 KB)
LinkDef.h (798 Bytes)
TTextToGraph.h (2.72 KB)
TTextToGraph.cxx (8.02 KB)

Hi,

The problem is that the compilation unit (for example the dictionary file) that need to instantiate the template must see the template declaration. In particular (for the symptom you point out), TTextToGraph::~TTextToGraph() is not instantiate because instead of being implemented in the header file (which is visible to the dictionary file) but is implemented in your .cxx file (which is not visible to any other source file).

The usual solution is to rename your (template) .cxx into .icc file and to include those in the corresponding .h files.

Cheers,
Philippe