Re: Problem with compiled program in Root V4.00/08 which works fine in ROOT V3.10/02

From: Christian Holm Christensen <>
Date: Mon, 14 Feb 2005 12:02:30 +0100

Hi Venkatesh,

On Sun, 2005-02-13 at 20:10 -0600, Venkatesh Kaushik wrote:
> Hi,
> I prepared a demo for my students sometime back with Root V3.10/02
> and the demo seems to be working fine, until I migrate the exact same
> program and compile it on Root V4.00/08. It compiles and links without
> a problem.
> I have attached the tarred zipped folder that contains the demo. The
> folder contains
> a README file for instructions on compiling/linking the programs in
> the folder.
> Can anyone please reproduce the problem on their machine and let me
> know if
> you have an explanation? Thank you for the help in advance

Your dynamic linker ( does not find the libraries it needs. Try

        ~/SharedClassDEMO> ldd ./MyVector
               => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => not found
       => /lib/tls/ (0x40037000)
       => /usr/lib/ (0x4003b000)
       => /lib/tls/ (0x400f5000)
       => /lib/ (0x40117000)
       => /lib/tls/ (0x40120000)
       => /lib/tls/ (0x4012f000)
                /lib/ => /lib/ (0x40000000)

As you can see, you need to tell the dynamic linker where to find the ROOT and user libraries. This can be done in several ways (in order of preference):

                ROOTLIBDIR := $(shell root-config --libdir)

        And define `LDFLAGS' as 
        	LDFLAGS		= -O -Wl,-rpath,$(ROOTLIBDIR):.
      * Finally, you can set some environment variable to specify where
        the dynamic linker should look for shared libraries.  On most
        POSIX platforms, the environment variable is `LD_LIBRARY_PATH',
        except for HP/UX where it's something else (I can't remember).
        On M$ Windoze it's `PATH' 

The reason I put environment variables last, is that they are notoriously easy to get wrong.

> Venkat.
> UTA, High Energy Physics Group
> /******************** With ROOT V4.00/08 on linux - problem running
> program**************/
> [venkat_at_www SharedClassDEMO]$ ls
> MainVector.cxx Makefile MyVector.cxx MyVector.h MyVector_LinkDef.h
> [venkat_at_www SharedClassDEMO]$ gmake
> g++ -O -Wall -fPIC -Wno-deprecated -pthread
> -I/data2/phys/d0/d0usr/products/root/Linux-2-4/v4_00_08b_eh/include -c
> MyVector.cxx
> Generating dictionary MyVectorDict.cxx...
> g++ -O -Wall -fPIC -Wno-deprecated -pthread


Due to this flag, you get a lot of

        In file included from /usr/include/c++/3.3/backward/iostream.h:31,
                         from MyVector.h:1,
                         from MyVector.cxx:1:
        /usr/include/c++/3.3/backward/backward_warning.h:32:2: warning:
        #warning This file includes at least one deprecated or
        antiquated header. Please consider using one of the 32 headers
        found in section of the C++ standard. Examples include
        substituting the <X> header for the <X.h> header for C++
        includes, or <sstream> instead of the deprecated header
        <strstream.h>. To disable this warning use -Wno-deprecated.

from newer GCC's. Please include either `iostream' or `Riostream.h'.

> /******************** With ROOT V3.10/02 on linux - works fine
> **************/

Why this is so, I can only speculate. The error you get has nothing to do with ROOT, and should not be contingent on which ROOT version you're using. Unless, of course, you're sourcing some script to use ROOT 3.10/02

        . ~/use_root_3.10.02

which contains a line that sets the environment variable LD_LIBRARY_PATH to include `.' or the current directory:

        export LD_LIBRARY_PATH=/opt/root/3.10/02/lib:.

See, the problem with `LD_LIBRARY_PATH' shows it ugly face once again :-) LD_LIBRARY_PATH is _evil_!


 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:               Web:
 | |
Received on Mon Feb 14 2005 - 12:04:09 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET