Funny problem with shared library

Hi,

I have a strange problem when I load two shared libraries - it seems as if when I load the second library, that root somehow doesn’t know (even though no errors are given): compare these two root sessions:

[coganp@pcp177897pcs example]$ root
root [0] gSystem->Load(“class1/libCLASS1shared.so”);
root [1] class1 b
root [2] .q

[coganp@pcp177897pcs example]$ root
root [0] gSystem->Load(“class2/libCLASS2shared.so”);
root [1] gSystem->Load(“class1/libCLASS1shared.so”);
root [2] class1 b
Error: Symbol class1b is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
root [3] .q

The libraries libCLASS2shared.so and libCLASS1shared.so are libraries with just a single empty placeholder class (Class1 and Class2) - I can provide the compilable example easily enough

I am using 5.22/00 on RH4 enterprise

thanks in advance for any help

Did you check the return value from gSystem->Load(…) ?

Rene

Hi Rene,

the return value is 0 in both cases - which I believe indicates a successful load

thanks
Peter

In this case, provide the strict minimum sources reproducing this problem.

Rene

Hi Rene,

I’ve attached a tgz which opens to a directory peterc

You should be able to run make from within. This goes into the two subdirectories class1 and class2 and compiles a shared library from a very simple essentially empty class.

When you open root from the peterc directory, you should be able to reproduce what I see.

many thanks
Peter
peterc.tar (20 KB)

You seem to have a problem with your Makefile that I have no time to investigate.
If you just do (with ACLIC)

root > .L class1/class1.cpp+ root > .L class2/class2.cpp+ root > class1 a root > class2 b
I do not see any problem.

Rene

Hi Rene,

I was able to reproduce what you did - but I am still stuck. The makefile I sent was a big mess. I was able to trim down the commands that are used to compile to the barest minimum and I still get the same issue. Maybe something is wrong here:

#!/bin/bash

DEFINE ROOT INCLUDE DIRECTORY##

rootInc=/usr/local/include/root/

COMPILE CLASS 1

cd class1;
g++ -o class1.o -c -fPIC -I$rootInc class1.cpp
rootcint -f root_dict.cpp -c class1.h LinkDef.h
g++ -fPIC -I$rootInc -c -o root_dict.o root_dict.cpp
g++ -shared -o libCLASS1shared.so class1.o root_dict.o

COMPILE CLASS 2##

cd …/class2
g++ -o class2.o -c -fPIC -I$rootInc class2.cpp
rootcint -f root_dict.cpp -c class2.h LinkDef.h
g++ -fPIC -I$rootInc -c -o root_dict.o root_dict.cpp
g++ -shared -o libCLASS2shared.so class2.o root_dict.o

thanks for any help
peter

Hi Peter,

You MUST name the dictionaries a different name otherwise only ONE of them will be loaded.

Cheers,
Philippe.

Hi Philippe,

that worked - I never would have thought of that being a problem. I thought so long as the shared libraries had different names it would be fine.

thanks for saving me much hair pulling

cheers
Peter