Home | News | Documentation | Download

Static Compilation of a ROOT Class Dictionary

Hi ROOT Developers,

I need to build a class dictionary and I would like to have everything embedded in the compiled executable of my program.
In particular, I am working with std::vector<std::vector<float> >, but I am interested in the more general problem.

This post clearly explains how to build the dictionary and a shared library.

At present, after generating the dictionary with rootcling, I am compiling my program directly against mydict.cxx file, that is:
gcc -o myProgram myProgram.cpp mydict.cxx ...
The program works and data are written to file.

In case the the file mydict_rdict.pcm is missing in the executable’s directory, the following error is raised during runtime:
Error in <TCling::LoadPCM>: ROOT PCM mydict_rdict.pcm file does not exist
but the program works fine nevertheless.

In conclusion, my questions: is it correct what I am doing? If not, is it possible - and how - to have everything needed to write/read arbitrary classes to/from TFiles embedded in the executable of a program?

Best regards,
Loris


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.20
Platform: MacOS & CentOS
Compiler: gcc


@oshadura or @vvassilev could you help with this one? Thanks!

The *rdict.pcm is mostly an optimization data structure. Your code will run but slower in some cases (notably in the context of MakeProject). In some cases, we use the information only available in the rdict files to load dependent libraries which have no explicit dependencies but that’s not your case IIUC.

I would recommend keeping all rootcling-produced artifacts (rootmap and rdict files) next to your binary.

Storing the rdict files in currently not supported. I have an idea how to do so but lack of bandwidth. I would be happy to guide you if you are willing to implement it :wink:

Thank you very much for your prompt reply.
Then, am I correctly understanding that compiling against the mydict.cxx and leaving all the other rootcling products next to the binary is the right thing to do?

Correct!

1 Like

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