Hi,
I wrote a few classes inherited from TObject, compiled it with rootcling, created libMyLib.so, libMyLib_rdict.pcm, libMyLib.rootmap, and added them to LD_LIBRARY_PATH.
When I get into the root interactive prompt, I can use Tab to show a list of classes defined in my codes. But when I try to run MyNamespace::MyClass a, I got message:
OOT_prompt_2:1:9: error: no member named 'MyClass' in namespace 'MyNamespace'
If I then type .L libMyLib.so and run MyNamespace::MyClass a again, everything is fine. It looks like that root can see what’s in my lib, but cannot automatically load it. What could be the cause?
Ineractive usage at the prompt, in macros and I/O
In this case you need to load your library containing your classes automatically and for that you need a rootmap file. You can achieve it like this:
They are in the same folder. I double checked my LD_LIBRARY_PATH. The folder is included. Another proof is that my ROOT prompt responds to my TAB key to complete my typing of the class and namespace names (even though it cannot run it). Attached please find a simplified package to demonstrate my problem.smpl.tar.gz (6.8 KB). Simply type make to generate lib, rootmap and pcm files.
I remember in ROOT5, rootmap file lists dependence between libs. But in ROOT6 rootmap file only contains information about my own lib. Could you please explain the reason of this difference?
You spotted it. That is indeed the problem. Once I switched from -s to -rml with other things the same, I could have the lib automatically loaded.
However, without -s libMyLib the name of the pcm file becomes MyLib_rdict.pcm instead of libMyLib_rdict.pcm. I guess the name does not matter much, but I end up with using both -s and -rml so that I can have the pcm file name consistent with other ROOT libs and still be able to have my own lib automatically loaded.