RootTalk


ROOT Discussion Forums

Autoloading of libraries in 5.34/00

Discuss installing and running ROOT here. Please post bug reports here.

Moderator: rootdev

Autoloading of libraries in 5.34/00

Unread postby jbattat » Wed Jul 11, 2012 19:14

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:
Code: Select all
> 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
Code: Select all
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):
Code: Select all
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...
Code: Select all
> 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:

Code: Select all
> 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:
Code: Select all
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
http://root.cern.ch/root/roottalk/roottalk01/1895.html):
Code: Select all
> 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
Code: Select all
> ls /usr/lib/root/libGraf.so
/usr/lib/root/libGraf.so*
jbattat
 
Posts: 15
Joined: Fri Sep 05, 2008 15:22

Re: Autoloading of libraries in 5.34/00

Unread postby pcanal » Wed Jul 11, 2012 19:41

Hi,

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

Philippe
pcanal
 
Posts: 6147
Joined: Wed Aug 27, 2003 14:22
Location: Fermilab

Re: Autoloading of libraries in 5.34/00

Unread postby jbattat » Wed Jul 11, 2012 19:52

Phillipe,

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

Code: Select all
> 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?
jbattat
 
Posts: 15
Joined: Fri Sep 05, 2008 15:22

Re: Autoloading of libraries in 5.34/00

Unread postby pcanal » Wed Jul 11, 2012 19:55

Yes, this is the problem. Try placing:
Code: Select all
-L/usr/lib/root -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf
at the _end_ of the link line.

Cheers,
Philippe.
pcanal
 
Posts: 6147
Joined: Wed Aug 27, 2003 14:22
Location: Fermilab

Re: Autoloading of libraries in 5.34/00

Unread postby jbattat » Wed Jul 11, 2012 20:48

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

To review, I moved
Code: Select all
-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:

Code: Select all
> 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.


Code: Select all
> 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.
jbattat
 
Posts: 15
Joined: Fri Sep 05, 2008 15:22

Re: Autoloading of libraries in 5.34/00

Unread postby pcanal » Wed Jul 11, 2012 20:53

Hi,

Q1: So the linking worked on SL5.7 with one g++ compiler but not on Ubuntu11.10 with another? (see below for compiler info).
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.

Q2: autoloading: shouldn't the libGraf.so library be loaded automatically when cint finds a reference to a TGraph in libMaxCam.so?
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.
pcanal
 
Posts: 6147
Joined: Wed Aug 27, 2003 14:22
Location: Fermilab

Re: Autoloading of libraries in 5.34/00

Unread postby jbattat » Wed Jul 11, 2012 21:19

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

James
jbattat
 
Posts: 15
Joined: Fri Sep 05, 2008 15:22


Return to ROOT Support

Who is online

Users browsing this forum: Google [Bot] and 2 guests