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

From: Christian Holm Christensen <cholm_at_nbi.dk>
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 (ld.so) does not find the libraries it needs. Try

        ~/SharedClassDEMO> ldd ./MyVector
                        libMyVector.so => not found
                libCore.so.4.01 => not found
                libCint.so.4.01 => not found
                libHist.so.4.01 => not found
                libGraf.so.4.01 => not found
                libGraf3d.so.4.01 => not found
                libGpad.so.4.01 => not found
                libTree.so.4.01 => not found
                libRint.so.4.01 => not found
                libPostscript.so.4.01 => not found
                libMatrix.so.4.01 => not found
                libPhysics.so.4.01 => not found
                libdl.so.2 => /lib/tls/libdl.so.2 (0x40037000)
                libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x4003b000)
                libm.so.6 => /lib/tls/libm.so.6 (0x400f5000)
                libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40117000)
                libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40120000)
                libc.so.6 => /lib/tls/libc.so.6 (0x4012f000)
                /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (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
> README
> [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 17.4.1.2 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_!

Yours,

-- 
 ___  |  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:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
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