Hi ROOTers.
Apologies to have to bring back up a topic I’ve already seen several instances of in the forums, but despite going through them all I’m still having trouble.
I’m trying to compile a ROOT script that utilizes custom classes. The class definitions are built into a shared library. I load with gSystem->Load(“thelibrary.so”), and in interactive mode, I have no issues. But when trying to compile my ROOT script with .L script.cc+, I get a series of “unknown type name” errors.
I’ve previously had problems and was able to solve them with the magic line R__LOAD_LIBRARY(path/to/library)
but this time all this does is print a slew of warnings about attempts to add the native ROOT classes to the TClassTable - but explicitly nothing about the classes I’m actually trying to load.
The dictionary is generated in a makefile via: [code]
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimPmtInfo.hh ./src/WCSimEnumerations.cc ./include/WCSimEnumerations.hh ./include/WCSimRootLinkDef.hh
rootcint: (ROOTSRC)
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootLinkDef.hh [/code]
while the library itself is generated via: [code]
ROOTOBJS := (G4WORKDIR)/tmp/(G4SYSTEM)/WCSim/WCSimRootEvent.o (G4WORKDIR)/tmp/(G4SYSTEM)/WCSim/WCSimRootGeom.o (G4WORKDIR)/tmp/(G4SYSTEM)/WCSim/WCSimPmtInfo.o (G4WORKDIR)/tmp/(G4SYSTEM)/WCSim/WCSimEnumerations.o (G4WORKDIR)/tmp/(G4SYSTEM)/WCSim/WCSimRootDict.o
(G4TMPDIR)/%.o: src/%.cc
@echo Compiling *.cc …
@if [ ! -d (G4TMPDIR) ] ; then mkdir (G4TMPDIR) ; echo mkdir (G4TMPDIR) ;fi
@echo (CXX) (CXXFLAGS) (CPPFLAGS) -c -o (G4TMPDIR)/(*F).o <
@(CXX) (CXXFLAGS) (CPPFLAGS) -c -o (G4TMPDIR)/(*F).o $<
libWCSimRoot.so : (ROOTOBJS) @g++ -shared -O ^ -o libWCSimRoot.so $(shell root-config --libs) [/code]
The code I’m using works fine with ROOT 5.34, so presumably the problem lies in the migration to ROOT 6. I think I need a rootmap file to specify the contents of the library? And possibly a pcm file, for I/O of the class? The relevant flags though are a little unclear to me:
In another thread Danilo clarified that [quote]The rml flag specifies the name of the library which should be autoloaded when a class, enum, variable or header file relevant to your selection is encountered[/quote]
That sounds like it should be the file containing my class definitions, libWCSimRoot.so.
Then the -s flag then seems to indicate, if my dictionary file (./src/WCSimRootDict.cc) is compiled into a library, then I should point to that here. Since WCsimRootDict.o is also included in libWCSimRoot.so, then I should also give -s LibWCSimRoot.so …
It seems I can omit the -rmf option, in which case it is “inferred from” the rml file. This could suggest this should be a pre-existing file, and the two must have the appropriate relative naming convention… in which case how do I generate that? But I think it is rather a product to be generated by the rootcint command, and it’s name will be taken from the rml file.
Similarly Danilo clarified that [quote] The pcm file is a special ROOT file and is necessary and should sit next to the library in which the dictionary it refers to has been compiled. It contains metadata to fill the ROOT typesystem at library load time, metadata used to do I/O of selected classes. The -m flag will be necessary in the future when the pcm files will not be ROOT files anymore but rather clang precompiled modules. It allows to specify a hierarchy, a tiered structure, of pre compiled modules.
[/quote]
That somewhat seems to tie up with my interpretation that this is for linking libraries to other libraries, or something similar. Since [quote] The pcm file produced by this invocation will not include any declarations already included in pcm files loaded with -m[/quote] but I don’t have any other .pcm files, and wish this one to contain all my custom classes, I take it I can leave this out.
Ultimately what seems to be missing from my makefile is the options for -s and/or -rml. They both sound like they should be libWCSimRoot.so. In the end I’ve attempted to modify things like this:
rootcling -f ./src/WCSimRootDict.cc -s libWCSimRoot.so -rml libWCSimRoot.so -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootLinkDef.hh
However, upon starting root, with libWCSimRoot.so, libWCSimRootDict.rootmap and WCSimRootDict_rdict.pcm in the current working directory, I get errors error: unknown type name 'WCSimRootEvent'
I have tried with variations of including -s, -rml, -rmf… but have not struck a lucky combination.
Clearly things are a little muddled for me. Can someone please help clarify things?