Re: problem linking examples in $ROOTSYS/test

From: ZVYAGIN (ZVYAGIN@mx.ihep.su)
Date: Tue Dec 07 1999 - 06:39:12 MET


Hi,

On Mon, 6 Dec 1999, Dirk Meier wrote:

> 
> Hi Rooters,
> 
> I installed `root_v2.23.Linux.2.2.3.egcs111.tar.gz'
> and I have a problem linking the examples in $ROOTSYS/test
> 
> 
> 
> The symptons are:
> 
> > make
> g++ -shared -g Event.o EventDict.o -o libEvent.so
> g++ -g MainEvent.o Event.o EventDict.o -L/usr/ROOT/root/lib -lNew -lCore
> -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix
> -lPhysics -lm -ldl -rdynamic -o Event
> MainEvent.o: In function `main':
> MainEvent.o(.text+0x271): undefined reference to `TFile::TFile(char const
> *, char const *, char const *, int)'
> MainEvent.o(.text+0x4e8): undefined reference to `TFile::TFile(char const
> *, char const *, char const *, int)'
> MainEvent.o(.text+0x5b8): undefined reference to
> `TDirectory::TDirectory(char const *, char const *, char const *)'
> collect2: ld returned 1 exit status
> make: *** [Event] Error 1
> 
> 
> I am on a linux RedHat 5.2 system
> 
> > less /proc/version
> Linux version 2.0.36 (root@porky.redhat.com) (gcc version 2.7.2.3) #1 Tue
> Oct 13 22:17:11 EDT 1998

I faced with analagous problem. I had several undefined refrences in linking 
time. One of this undefined symbols was
TTree::Scan(char const *, char const *, char const *, int, int)
But 'nm' command under linux reported that this symbol presented both in 
library $ROOTSYS/lib/libTree.so and my object file:

$ nm -C $ROOTSYS/lib/libTree.so
0004dba8 T TTree::Scan(char const *, char const *, char const *, int, int)

$ nm -C myobject.o
         U TTree::Scan(char const *, char const *, char const *, int, int)

The key point was to skip option '-C' (that produces C++ names). After that:

$ nm $ROOTSYS/lib/libTree.so
0004dba8 T Scan__5TTreePCcT1PCcii

$ nm myobject.o
         U Scan__5TTreePCcN21ii

You see that these are different symbols. The reason of this difference is 
simple: I used gcc-2.95 compiler (latest gcc version) but root was 
compiled with another version of gcc (or egcs). And the algorithm for 
C++ names creation has changed a bit.

How to solve the problem? Either use the same compiler as it was used in 
compiling ROOT binaries, or recompile ROOT from source by your compiler. 

But at first check: do your object file and library libCore.so have the same 
name for TFile::TFile(char const *, char const *, char const *, int) or 
not. In my ROOT version (compiled with gcc-2.95.2) the name is

000adaa0 T __5TFilePCcN21i
           ^^^^^^^^^^^^^^^

With best wishes,
Alexander.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET