Warning: Unused class rule:

This issue was discussed in the forum but the response is a bit too technical for me to digest. I would appreciate specific inputs for my issue here. The warning message is:

   Warning: Unused class rule: ana_syns

The LinkDef.h contains:

  #pragma link C++ class ana_syns+;

The corresponding rootcling command is:

  /ROOT/bin/rootcling -v2 -f G__ana_syns.cxx -s /ana/build/src/libana_syns.so -rml libana_syns.so -rmf /ana/build/src/libana_syns.rootmap -compilerI/usr/include/c++/9 -compilerI/usr/include/x86_64-linux-gnu/c++/9 -compilerI/usr/include/c++/9/backward -compilerI/usr/lib/gcc/x86_64-linux-gnu/9/include -compilerI/usr/local/include -compilerI/usr/include/x86_64-linux-gnu -compilerI/usr/include -compilerI/usr/lib/gcc/x86_64-linux-gnu/9/include -compilerI/usr/local/include -compilerI/usr/include/x86_64-linux-gnu -compilerI/usr/include -I/ana -I/home/root6.26.08/include -I/ana/src src/ana_syns.h /ana/src/LinkDef.h

Hi @wx2017 ,

the warning means that rootcling is not actually generating a dictionary for class ana_syns: it sees that the linkdef file has a rule for it, but it doesn’t see that class in the headers passed to it. In fact, are you passing a header with the declaration of the class to rootcling?

In case it’s useful here are some examples of dictionary generation techniques: GitHub - eguiraud/root_dictionaries_tutorial: A tutorial on creating ROOT dictionaries to perform I/O of custom C++ classes .


1 Like

Thanks @eguiraud . Can you please be a bit more specific on the following:

In fact, are you passing a header with the declaration of the class to rootcling ?

I’m using cmake in the way described in the link you mentioned above.

What is the content of:

The issue is bit more complicated than I thought. Here is the LinkDef.h:

 #ifdef __CLING__
 #pragma link off all globals;
 #pragma link off all classes;
 #pragma link off all functions;

 #pragma link C++ class ana_eff_tree+;
 #pragma link C++ class ana_syns+;


When rootcling run on ana_syns, it generates the dictionary file for ana_syns but complains “Unused class rule” on ans_eff_tree. When rootcling run on ana_eff_tree, it also generates dictionary file for ana_eff_tree but complains “Unused class rule” on ana_syns. If I create a separate LinkDef file for each files, then there’s no warning messages. Does that mean we can’t group all different classes into a single LinkDef files?

OK. It’s due to the set up in my cmake file which produce a separate dictionary files for each class. After goup them together to produce a single dictionary file, there’s no warning messages anymore. Somethings like the following:

  foreach(main_file ${MAIN_FILES})
    get_filename_component(barename ${main_file} NAME_WE) # get the name without the extension
    LIST(APPEND head_file_list src/${barename}.h)

  ROOT_GENERATE_DICTIONARY(dict ${head_file_list} LINKDEF LinkDef.h)

This meant that you were passing to rootcling only one of the 2 headers at a time when both are needed.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.