Dictionary generation in 2 interdependent packages

Dear ROOTers,
I have 2 packages in separate directories on my build, say Pack1 and Pack2. On Pack1 I build a dictionary for some of the classes DictPack1 and everything is put in a dynamic lib. On Pack2 I have some classes that #include headers from Pack1 and I tru to build a dictionary there. I have tried two things:

  1. Use a LinkDef.h file in Pack2 where I only have one line #pragma link C++ MyPack2Class
    In this case a big dictionary is generated where all the classes of Pack1 are again included with probably new streamers etc. Won’t this be a problem if both dictionaries are linked to the same image? In addition, MyPack2Class does not get entries in the dictionary, nothing is generated about this class, which is very weird! (And when trying to load Pack2.so I get that there is no member inspector for MyPack2Class).

  2. I do not use a LinkDef.h file. In this case dictionary is generated with entries for MyPack2Class but there is no reference to the dependent classes of Pack1. This could probably be correct, however the problem is that within ROOT or a test executable, when I do gSystem->Load(“Pack1.so”) it loads with ret code 1 and then gSystem->Load(“Pack2.so”) fails with unresolved externals from Pack1! Is this normal, since the previous statement actually loads these symbols?

I suppose that in ROOT you build several inter-dependent dictionaries. Is there any special care that should be taken from your experience? Thanks,

filimon

[quote]1) Use a LinkDef.h file in Pack2 where I only have one line #pragma link C++ MyPack2Class
In this case a big dictionary is generated where all the classes of Pack1 are again included with probably new streamers etc. [/quote]This is very unusual! Where are the pragma statement for the Pack1 classes?

[quote]In addition, MyPack2Class does not get entries in the dictionary, nothing is generated about this class, which is very weird! (And when trying to load Pack2.so I get that there is no member inspector for MyPack2Class).[/quote]Humm … so it sounds like you have multiple file name LinkDef.h and that they are all in your include path.

[quote]2) I do not use a LinkDef.h file. [/quote]This method would work only if you have one class per dictionary (unless you also add pragma to the header files directly … but that would bring back to seeing behavior similar to your number 1).

Bottom, you probably simply need to name each of the linkdef file differently (Pack1LinkDef.h, Pack2LinkDef.h) and/or insure that they are not on your include path.

Cheers,
Philippe.

Hi Philippe,
it was a more naive problem actually. My LinkDef files have a lot of #pragma, mainly to handle namespaces. The problem was that for MyPack2Class I had a pragma like this:
#pragma link C++ name::space::MyPack2Class;
What is missing but is not obvious immediately is the word “class” so it becomes:
#pragma link C++ class name::space::MyPack2Class;
So rootcint does not do anything because the syntax is wrong but it would be helpfull to produce an error message for this kind of syntactic error. Taking a look at root.cern.ch/root/Cint.phtml?ref
I have the impression that it would be possible when there is a line #pragma link C++ to demand that it is followed by [class|struct|union|enum|namespace|protected]. I think this is not the case now, so rootcint silently ignores the input. Anyway, everything works ok for me now. To be safe I named the LinkDef.h files differently also in each package. Thanks,

filimon