Hello.cxx

hello,

as i´m starting with root, i try to compile some of the examples in /test, which should work without problems, as far as i can understand.
but i allways get compiler-errors, that “_isnan” and “_finite” are undeclared in “TMath”. (e.g. in “Hello.cxx”).
as a workaround i tried to include , which led to a big variety of linker errors, saying that the references to all methods in the classes used are not defined.
this is probably a very silly problem but nevertheless one that i can´t get rid of, so i´m asking for help.

best regards

alex

Hi Alex,

Which version of ROOT are you using? On which platform? Have you set ROOTSYS and LD_LIBRARY_PATH before to compile the examples in $ROOTSYS/test directory?

I see no problem to compile this example.

Cheers, Ilka

hi ilka,

sorry, my information weren´t very exhaustive.
i installed root 5.02/00 to use within the cygwin-bash under windows2000.
i tried to compile “hello.cxx” with mingw/gcc3.4.2, telling it to search for libraries in $rootsys/lib (and for completeness also in $rootsys/cint/lib).

cheers

alex

Hi,
mingw ("–no-cygwin") is not supprted. User the “regular” cygwin gcc instead. If what I’m saying doesn’t make sense to you then lpease provide us with the exact lines you were executing, so I can copy & paste and run it and see the error message.
Axel.

hello again,

as proposed, i used gcc provided by cygwin, but when i try this:

g++ $ROOTSYS/test/hsimple.cxx -o $ROOTSYS/test/hsimple -I $ROOTSYS/include -L $ROOTSYS/lib

i get these errors (i used “hsimple.cxx” because the error-log is comparably short:)

/Temp/ccG42G4b.o:hsimple.cxx:(.text+0xaa): undefined reference to TFile::TFile(char const*, char const*, char const*, int)' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x10a): undefined reference toTH1F::TH1F(char const*, char const*, int, double, double)’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x130): undefined reference to TObject::operator delete(void*)' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x1c9): undefined reference toTH2F::TH2F(char const*, char const*, int, double, double, int, double, double)’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x1ef): undefined reference to TObject::operator delete(void*)' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x284): undefined reference toTProfile::TProfile(char const*, char const*, int, double, double, double, double, char const*)’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x2aa): undefined reference to /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x31b): undefined reference to TNtuple::TNtuple(char const*, char const*, char const*, int)' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x393): undefined reference toTObject::operator delete(void*)’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x3cf): undefined reference to _gRandom' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x3f0): undefined reference to_gRandom’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x426): undefined reference to _gRandom' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x43b): undefined reference to_gRandom’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x5af): undefined reference to TFile::Write(char const*, int, int)' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x5c5): undefined reference toTFile::Close(char const*)’
/Temp/ccG42G4b.o:hsimple.cxx:(.text+0x5dd): undefined reference to TFile::~TFile()' /Temp/ccG42G4b.o:hsimple.cxx:(.text+0x60d): undefined reference toTFile::~TFile()’
/Temp/ccG42G4b.o:hsimple.cxx:(.text$_ZN7TObjectnwEj[TObject::operator new(unsigned int)]+0xd): undefined reference to `TStorage::ObjectAlloc(unsigned int)'
collect2: ld returned 1 exit status

any hints, what´s wrong?

thanks a lot

alex

You must specify the list of librariies to link with:
To see the list run

root-config --glibs
I strongly recommend to use this small utility (in $ROOTSYS/bin)
in your script. eg replace

g++ $ROOTSYS/test/hsimple.cxx -o $ROOTSYS/test/hsimple -I $ROOTSYS/include -L $ROOTSYS/lib by

g++ $ROOTSYS/test/hsimple.cxx -o $ROOTSYS/test/hsimple `root-config --cflags --glibs`
Rene

hello brun,

when i type in what you suggested, then i get a huge error message, by far too long to be cited here. for an idea i just put the first few lines here:

collect2: ld terminated with signal 1 [Hangup]
$ROOTSYS/lib/libCore.dll.a:misc-inst.cc:(.text+0x51550c): multiple definition of TObject::operator new(unsigned int)' /Temp/cc7K3ggY.o:hsimple.cxx:(.text$_ZN7TObjectnwEj[TObject::operator new(unsigned int)]+0x0): first defined here $ROOTSYS/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): multiple definition of__imp__G__globalvarpointer’
$ROOTSYS/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): first defined here
$ROOTSYS/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): multiple definition of __imp__optind' $ROOTSYS/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): first defined here $ROOTSYS/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x0): multiple definition of___do_sjlj_init’
$ROOTSYS/lib/libCore.dll.a:misc-inst.cc:(.text+0x0): first defined here

as input i used exactly what you wrote.

alex

Hi Alex,

with any recent root version please also use the following compiler flags:
-pipe -Wall -Woverloaded-virtual -D_DLL -I/usr/X11R6/include

and these linker flags;
-Wl,–enable-auto-import -Wl,–enable-runtime-pseudo-reloc -L/usr/X11R6/lib

You are compiling and linking in one go - at least for testing purposes it’s better to split that up. So please try g++ `root-config --cflags` -pipe -Wall -Woverloaded-virtual -D_DLL -I/usr/X11R6/include -c $ROOTSYS/test/hsimple.cxx g++ `root-config --glibs` -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -L/usr/X11R6/lib $ROOTSYS/test/hsimple.o -o $ROOTSYS/test/hsimple

Or you could just run “cd $ROOTSYS/test; make hsimple.exe”.
Axel.

hi,

uhh, it`s me again…

good news is, that the method suggested by axel works fine on the pc of my colleague. the bad news is, that neither of the two work on my pc.

in both cases i get this while linking (compiling does what it should):

/cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): multiple definition of __imp__G__globalvarpointer' /cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): first defined here /cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): multiple definition of__imp__optind’
/cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): first defined here
/cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x0): multiple definition of ___do_sjlj_init' /cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x0): first defined here /cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x1082): multiple definition of_G__int_cast’
/cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b1890): first defined here
/cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x354f): multiple definition of `_G__exec_tempfile’
/cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b17b0): first defined here

the main diffrence between the two pcs is that my root was installed from binaries. is that a problem?

alex

Hi,
could you post the exact line you tried to execute? Could you run “rm hsimple.o hsimple.exe; make hsimple.exe”, and send the output, including the lines executed by make? What g++ version do you use (g++ --version)?
Cheers, Axel.

hi axel,

many thanks for your help.

here the output you asked for:

g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
Copyright © 2004 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++ -O -pipe -Wall -Woverloaded-virtual -I/usr/X11R6/include -D_REENTRANT -MD -I/cygdrive/d/Root/include -c hsimple.cxx
g++ -O -Wl,–enable-auto-import -Wl,–enable-runtime-pseudo-reloc -L/usr/X11R6/lib hsimple.o -L/cygdrive/d/Root/lib -Wl,-u,_G__cpp_setupG__Hist -Wl,-u,_G__cpp_setupG__Graf1 -Wl,-u,_G__cpp_setupG__G3D -Wl,-u,_G__cpp_setupG__GPad -Wl,-u,_G__cpp_setupG__Tree -Wl,-u,_G__cpp_setupG__Rint -Wl,-u,_G__cpp_setupG__PostScript -Wl,-u,_G__cpp_setupG__Matrix -Wl,-u,_G__cpp_setupG__Physics -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lpthread -lm -o hsimple.exe
/cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): multiple definition of __imp__G__globalvarpointer' /cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xd28): first defined here /cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): multiple definition of__imp__optind’
/cygdrive/d/Root/lib/libCore.dll.a:crtstuff.c:(.idata+0xa78): first defined here
/cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x0): multiple definition of ___do_sjlj_init' /cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x0): first defined here /cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x1082): multiple definition of_G__int_cast’
/cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b1890): first defined here
/cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x354f): multiple definition of _G__exec_tempfile' /cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b17b0): first defined here /cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x3aa9): multiple definition of_G__load_text’
/cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b1900): first defined here
/cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x161b8): multiple definition of _G__close_inputfiles' /cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b1720): first defined here /cygdrive/d/Root/lib/libCint.dll.a:streambuf-inst.cc:(.text+0x16d81): multiple definition of_G__const_setnoerror’
/cygdrive/d/Root/lib/libCore.dll.a:misc-inst.cc:(.text+0x4b1740): first defined here

i posted only the first few lines of the error-log which is roughly 6mb big…

alex

Hi,

looks like you’re right - this seems to be a mismatch between the compiler version used for the binary distribution and your compiler. With my root built from sources I cannot reproduce this problem either. So you’ll have to build root from sources, I’m afraid…

Cheers, Axel.

hi,

with root build from sources (which became possible with the hints mentioned in the topic “Probably a simple problem…” in this forum) everything works just fine!

big thanks to everyone

alex