Loading plugin class from source code, not shared lib

Hi,

I’ve been using the plugins facility of ROOT quite a lot in my development recently,
using it to load “on demand” classes from shared library files. It’s great !! :laughing:

I’m having trouble doing the same thing using a “macro” i.e. the source code for a
plugin class instead of a precompiled shared lib.

I have a class NewVarGlob1 defined in a ‘.h’ and ‘.cpp’ file with the same name. This class inherits from KVVarGlob1, which is in a library I already loaded into memory. I added to my ‘.rootrc’ file the following line:

Plugin.KVVarGlob: NewVarGlob1 NewVarGlob1 “NewVarGlob1.cpp+” “NewVarGlob1()”

The files NewVarGlob1.cpp/h are in the working directory. If I type gROOT->LoadMacro(“NewVarGlob1.cpp+”) the class is compiled and loaded, and I can use it.

However, if I try to use the plugin manager, something is wrong. First of all, if I type gROOT->GetPluginManager()->Print(), I see:
KVVarGlob NewVarGlob1 NewVarGlob1 “NewVarGlob1.cpp+” []
the [
] at the end of the line meaning “plugin not available”.
Indeed, if I retrieve the plugin handler with
TPluginHandler* ph = (TPluginHandler*)gROOT->GetPluginManager()->FindHandler(“KVVarGlob”,“NewVarGlob1”)
then do
root [5] ph->CheckPlugin()
(Int_t)(-1)
the plugin is effectively not available. But if I do ph->Inspect(), I see that the object is correctly initialised:
fBase=KVVarGlob
fRegexp=NewVarGlob1
fClass=NewVarGlob1
fPlugin="NewVarGlob1.cpp+"
fCtor=NewVarGlob1()
except for
fIsMacro=false

I do not understand why fMacro=false? According to the code, this is intialised in the constructor of TPluginHandler based on the result of
if (gROOT->LoadMacro(pluginName, 0, kTRUE) == 0)
fIsMacro = kTRUE;
When I type gROOT->LoadMacro(“NewVarGlob1.cpp+”,0,kTRUE) I get 0, so
why is fIsMacro set to false ?
It seems that if fIsMacro were true then everything would be alright…

Can anybody help me please ?
Best regards
John Frankland
GANIL

Use:

Plugin.KVVarGlob: NewVarGlob1 NewVarGlob1 NewVarGlob1.cpp+ "NewVarGlob1()" Aka no quote around the filename.

Cheers,
Philippe