Home | News | Documentation | Download

Autoloading of libraries in 5.34/00


#1

Hi folks,

I’m working in ROOT 5.34/00 on Ubuntu 11.10. I have built a library of functions that, not surprisingly, relies on ROOT functions. Attempts to load my library in CINT fail because the ROOT libraries are not auto-loaded. If I manually load the required ROOT libraries, my library works as expected. I do not see this problem in ROOT 5.32 on Scientific Linux 5.7. Details on both systems and symptoms are below. Suggestions are very welcomed!

James

First, the machine on which the libraries do not load correctly:

> uname -a
Linux dmatter-OptiPlex-GX620 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011 i686 i686 i386 GNU/Linux
> root-config --version
5.34/00
> root -l
root [0] gDebug=6
(const int)6

Tab-completion shows that the location of the ROOT libraries is known

root [2] gSystem->Load("libGraf
libGraf3d.so
libGraf.rootmap
libGraf3d.rootmap
libGraf.so

But when I load my library that depends on the ROOT libraries, the ROOT libraries are not autoloaded, I get an error message (and no indication that auto-loading of ROOT libraries was attempted):

root [1] gSystem->Load("libMaxCam.so");
dlopen error: /home/dmatter/dmtpc/projects/DarkMatter/MaxCam/libMaxCam.so: undefined symbol: _ZTI6TGraph
Load Error: Failed to load Dynamic link library /home/dmatter/dmtpc/projects/DarkMatter/MaxCam/libMaxCam.so
Info in <TUnixSystem::Load>: loaded library /home/dmatter/dmtpc/projects/DarkMatter/MaxCam/libMaxCam.so, status -1

Next up, a configuration that does work. Scientific Linux 5.7, ROOT 5.32/00 (and the debug messages show that the ROOT libraries are auto-loaded…

> uname -a
Linux noether.lns.mit.edu 2.6.18-308.8.2.el5 #1 SMP Tue Jun 12 11:25:25 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
> root-config --version
5.32/00
> root -l
root [0] gDebug = 6
(const int)6
root [1] gSystem->Load("libMaxCam.so");
Info in <TCint::AutoLoadCallback>: loaded dependent library libMathCore.so for class TGeoVolumeAssembly
...
Info in <TCint::AutoLoad>: loaded library libGX11TTF.so for class TGX11TTF
Selected visual 0x21: depth 24, class 4, colormap: default

Is there a difference in the AutoLoading in 5.34? Do I need to explicitly activate this? Note, that if I manually load the required ROOT libraries, the my libMaxCam.so loads successfully:

> root -l
root [0]  gSystem->Load("libGraf.so");
root [1]   gSystem->Load("libPhysics.so");
root [2]   gSystem->Load("libTree.so");
root [3]   gSystem->Load("libMinuit.so");
root [4] gSystem->Load("libMaxCam.so");

And tab-completion recognizes the functions in my library:

root [5] MaxCamImage
MaxCamImageTools::BLUR_EDGE_BEHAVIOR
MaxCamImageTools::BILATERAL_VALUE_FN
MaxCamImageTools::GRADIENT_OPERATOR
MaxCamImageTools::ANISOTROPIC_DIFFUSION_FN
MaxCamImageTools::ELLIPSE_PARAMETERS
MaxCamImage
MaxCamImageTools
root [5] MaxCamImage

Apologies if this is a trivial problem, but I could not find a fix in the documentation.

Oh, also, when creating libMaxCam.so I do link to the required ROOT libraries (as suggested in
root.cern.ch/root/roottalk/roottalk01/1895.html):

> g++ -shared -O2 -m32 -L/usr/lib/root -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf <...truncated...> -o libMaxCam.so

and (for example), libGraf.so is in /usr/lib/root

> ls /usr/lib/root/libGraf.so 
/usr/lib/root/libGraf.so*

#2

Hi,

This should work …even more so that the autoloading should made unnecessary by the fact that you explicitly linked the libraries. What does:which root.exe ldd `which root.exe` echo $ROOTSYS ldd /home/dmatter/dmtpc/projects/DarkMatter/MaxCam/libMaxCam.soprints?

Philippe


#3

Phillipe,

Thank you for the quick reply. Here’s the output you requested.

> which root.exe
/usr/bin/root.exe
> ldd `which root.exe`
	linux-gate.so.1 =>  (0x00ce8000)
	libCore.so => /usr/lib/root/libCore.so (0x00ce9000)
	libRint.so => /usr/lib/root/libRint.so (0x0042b000)
	libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x0047b000)
	libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x003a7000)
	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00110000)
	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x0012b000)
	libCint.so => /usr/lib/root/libCint.so (0x006e3000)
	libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x002a7000)
	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x002ac000)
	/lib/ld-linux.so.2 (0x006c3000)
> echo $ROOTSYS
/usr/
> ldd /home/dmatter/dmtpc/projects/DarkMatter/MaxCam/libMaxCam.so 
	linux-gate.so.1 =>  (0x00d5a000)
	libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x0044f000)
	libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x0053a000)
	libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x00564000)
	libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00649000)
	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00664000)
	/lib/ld-linux.so.2 (0x00f18000)

So it looks like the ROOT libraries are not actually explicitly linked to libMaxCam.so?


#4

Yes, this is the problem. Try placing:-L/usr/lib/root -lGui -lCore -lCint -lRIO -lNet -lHist -lGrafat the end of the link line.

Cheers,
Philippe.


#5

Great! That fixed it. Thank you! (but see below for follow-up questions).

To review, I moved

-L/usr/lib/root -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf

just before the -o in the linking command.

Q1: So the linking worked on SL5.7 with one g++ compiler but not on Ubuntu11.10 with another? (see below for compiler info).

Q2: autoloading: shouldn’t the libGraf.so library be loaded automatically when cint finds a reference to a TGraph in libMaxCam.so? Or does libGraf.so have to be explicitly linked to libMaxCam.so (which is what appears to be the case)? In other words, when I create a new ROOT session and create an instance of a TGraph at the cint prompt, libGraf.so is automatically loaded. But this appears not to be the case when custom shared libraries are loaded?

Thank you again!
James

For reference, here are the specs on the g++ compilers that I was using:

> g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> g++ --version
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#6

Hi,

[quote]Q1: So the linking worked on SL5.7 with one g++ compiler but not on Ubuntu11.10 with another? (see below for compiler info).[/quote]Yes, Ubuntu changed the default behavior of linking to ignore any library that is not needed by whatever is seeing before the library in the link line.

[quote]Q2: autoloading: shouldn’t the libGraf.so library be loaded automatically when cint finds a reference to a TGraph in libMaxCam.so?[/quote]It is not clear to me why this worked and does not work anymore but this is likely to be related to the switch to relying on explicitly linking in more places.

Philippe.


#7

Very good. Thank you once again for all of your help, it is much appreciated!

James