Share lib not recognized

I created a share lib, i.e. lib_production.so. When manually load it using "gsystem->Load(“lib_production.so”), then manually execute the following command “production pd” works. If putting everything in a macro, i.e.

{
gSystem->Load(“lib_production.so”);
production pd;
}

it complains the “production” is not defined. I must have missed something. Any help is appreciated. A copy of the lib_production.so can be found at:

https://www.physics.purdue.edu/~wxie/tmp/

ROOT Version: 6.16/00
Platform: ubuntu 18.04
Compiler: g++


Hi,

I think this is not supported by cling: the interpreter is backed by a real compiler. Therefore, it cannot know what the production type is at interpretation time.
You can:

  1. Include the header where production is defined
  2. use the R__LOAD_LIBRARY(lib_production); as it is done in this example https://root.cern/doc/master/copytree_8C.html

Cheers,
P

Thanks. It works. Actually so without including “gSystem->Load()” and "#include “production.h”, i.e.
just the following code works:

R__LOAD_LIBRARY(./lib_production.so)
void oo()
{
production pd;
}

Does that mean “gSystem->Load” is an old feature of ROOT4 or ROOT5 and we can just use R_LOAD_LIBRARY?

Hi,

no, it is not. I think R_LOAD_LIBRARY loads a library at parsing time, “gSystem->Load” at runtime. If it works for you w/o including headers, it means that the library contains some dictionaries and ROOT is able to parse the necessary headers behind the scenes.

Cheers,
P

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