Error compiling a program with ROOT 5.32 Kubuntu11.10 64bit

Dear all,
I’ve compiled ROOT 5.32 in my Kubuntu 11.10 64bit without any problems (I think). The output of ./configure is this one

[quote]Checking for source directory … /home/pereira/Downloads/root
Configuring for linuxx8664gcc
Checking for GNU Make version >= 3.80 … ok
Checking for C compiler … gcc
Checking for C++ compiler … g++
Checking for linker (LD) … g++
Checking for F77 compiler … gfortran
Checking for libX11 … /usr/lib/x86_64-linux-gnu
Checking for X11/Xlib.h … /usr/include
Checking for X11/xpm.h … /usr/include
Checking for X11/Xft/Xft.h … /usr/include
Checking for X11/extensions/shape.h … /usr/include
Checking for libXpm … /usr/lib
Checking for libXft … /usr/lib/x86_64-linux-gnu
Checking for libXext … /usr/lib/x86_64-linux-gnu
Checking for freetype-config … /usr/bin/freetype-config
Checking for libfreetype version >= 9.3.0 … ok
Checking whether to build included libfreetype6 … no
Checking for pcre-config … /usr/bin/pcre-config
Checking for libpcre version >= 3.9 … ok
Checking whether to build included libpcre … no
Checking for zlib.h … /usr/include
Checking for libz … /usr/lib/x86_64-linux-gnu
Checking whether to build included zlib … no
Checking for lzma.h … no
Checking for liblzma … no
Checking whether to build included lzma … yes
Checking for GL/gl.h … /usr/include
Checking for libGL, or libMesaGL … /usr/lib/x86_64-linux-gnu
Checking for libGLU, or libMesaGLU … /usr/lib/x86_64-linux-gnu
Checking for GL/glew.h … /usr/include
Checking for libGLEW … /usr/lib
Checking whether to build included GLEW … no
Checking for pkg-config … /usr/bin/pkg-config
Checking for libftgl … ok
Checking for ftgl version > 2.1.2 … ok
Checking whether to build included libftgl … no
Checking for mysql_config … /usr/bin/mysql_config
Checking for libmysqlclient version >= 3.23.* … ok
Checking for mysql.h … /usr/include/mysql
Checking for occi.h … no
Checking for libclntsh, or oci … no
Checking for libocci, or oraocci10 … no
Checking for libpq-fe.h … no
Checking for libpq … no
Checking for sql.h … no
Checking for libsqlod … no
Checking for sqlext.h … no
Checking for libiodbc, libodbc, or odbc32 … no
Checking for rfio_api.h … no
Checking for librfio, libdpm, libshift, shiftmd, or shift … no
Checking for rfio_api.h … no
Checking for stager_api.h … no
Checking for libshift, shiftmd, or shift … no
Checking for gfal_api.h … no
Checking for libgfal … no
Checking for ApMon.h … no
Checking for libapmoncpp … no
Checking for fftw3.h … /usr/include
Checking for libfftw3, or libfftw3-3 … /usr/lib
Checking for fitsio.h … /usr/include
Checking for libcfitsio, or cfitsio … /usr/lib
Checking for gvc.h … /usr/include/graphviz
Checking for libgvc, or gvc … /usr/lib
Checking for libgraph, or graph … /usr/lib
Checking for libcdt, or cdt … /usr/lib
Checking for libpathplan, or pathplan … /usr/lib
Checking for libexpat, or expat … /usr/lib/x86_64-linux-gnu
Checking for libgvplugin_dot_layout, or gvplugin_dot_layout … /usr/lib/graphviz
Checking for libPythia6 … no
Checking for Pythia.h … no
Checking for libpythia8 … no
Checking for dcap.h … no
Checking for libdcap … no
Checking for chirp_reli.h … no
Checking for libchirp_client … no
Checking for hdfs.h … no
Checking for jni.h … no
Checking for libhdfs … no
Checking for libjvm … no
Checking for dns_sd.h … /usr/include
Checking for libdns_sd … /usr/lib/x86_64-linux-gnu
Checking for avahi-client/client.h … /usr/include
Checking for avahi-common/strlst.h … /usr/include
Checking for avahi-core/core.h … no
Checking for libavahi-client … /usr/lib/x86_64-linux-gnu
Checking for libavahi-common … /usr/lib/x86_64-linux-gnu
Checking for libavahi-core … no
Checking for libglite-api-wrapper … no
Checking for gapiUI.h … no
Checking for libgapiUI … no
Checking for jpeglib.h … no
Checking for png.h … no
Checking for tiffio.h … no
Checking for gif_lib.h … no
Checking for libjpeg … no
Checking for libtiff … no
Checking for libungif … no
Checking for libz … /usr/lib/x86_64-linux-gnu
Checking for libpng … no
Checking whether to build included libAfterImage … yes
Checking for ldap.h … /usr/include
Checking for libldap … /usr/lib/x86_64-linux-gnu
Checking for liblber … /usr/lib/x86_64-linux-gnu
Checking for Python.h … /usr/include/python2.7
Checking for python2.7, libpython2.7, libpython, python, or Python … /usr/lib
Checking for xml2-config … /usr/bin/xml2-config
Checking for libxml2 version >= 2.4.x … ok
Checking for XrdVersion.hh … no
Checking for libssl … /usr/lib/x86_64-linux-gnu
Checking for libcrypto … /usr/lib/x86_64-linux-gnu
Checking for openssl/bio.h … /usr/include
Checking for openssl/blowfish.h … /usr/include
Checking for openssl/err.h … /usr/include
Checking for openssl/pem.h … /usr/include
Checking for openssl/rand.h … /usr/include
Checking for openssl/rsa.h … /usr/include
Checking for t_server.h … no
Checking for libsrp … no
Checking for libgmp … no
Checking for libmisc … no
Checking for pwauth.h … no
Checking for krb5.h … /usr/include
Checking for krb5.h redirect … /usr/include/krb5/krb5.h
Checking for krb5_c_valid_cksumtype in krb5.h … yes
Checking for valid_cksumtype in krb5.h … no
Checking for libk5crypto … /usr/lib/x86_64-linux-gnu
Checking whether we’re using MIT Kerberos … yes
Checking for krb5_c_valid_cksumtype in /usr/lib/x86_64-linux-gnu/libk5crypto.so … no
Checking for valid_cksumtype in /usr/lib/x86_64-linux-gnu/libk5crypto.so … no
Either ‘krb5_c_valid_cksumtype’ or ‘valid_cksumtype’ are available; disabling krb5
Checking for shadow passwords … yes
Checking for gsl/gsl_version.h … /usr/include
Checking for GSL version >= 1.8 … ok
Checking for libgsl, gslML, or gsl … /usr/lib
Checking for libgslcblas, gslcblasML, gslcblas, or cblas … /usr/lib
Checking whether /usr/lib/libgsl.a is compiled with -fPIC … yes
Checking whether /usr/lib/libgslcblas.a is compiled with -fPIC … no
Checking for shared library versions using gsl-config … yes
Checking whether to build libMathMore … yes
Checking whether to build libGenVector … yes
Checking whether to build libCintex … yes
Checking whether to build libReflex … yes
Checking whether to build libRooFit … no
Checking whether to build libMinuit2 … no
Checking whether to build libUnuran … no
Checking whether to build libGdml … no
Checking whether to build libTable … no
Checking whether to build libTMVA … yes
Checking whether to build libMemStat … yes
Checking for Clarens support … no
Checking for PEAC support … no
Checking whether to build afdsmgrd … no
Checking whether to integrate experimental cling … no
Checking what type of dictionaries to build … cint
Checking whether setresuid declared in /usr/include/unistd.h … yes
Creating include … done
Creating bin … done
Creating lib … done
Writing config/Makefile.config … done
Writing config/Makefile.comp … done
Writing include/RConfigure.h … done
Writing include/RConfigOptions.h … done
Writing bin/root-config … done
Writing etc/system.rootrc … done
Writing etc/system.rootauthrc … done
Writing etc/system.rootdaemonrc … done
Writing etc/root.mimes … done
Writing etc/daemons/rootd.rc.d … done
Writing etc/daemons/rootd.xinetd … done
Writing etc/daemons/proofd.rc.d … done
Writing etc/daemons/proofd.xinetd … done
Writing main/src/proofserv.sh … done
Writing main/src/roots.sh … done
Writing bin/memprobe … done
Writing build/misc/root-help.el … done
Writing macros/html.C … done
Writing bin/thisroot.sh … done
Writing bin/thisroot.csh … done
Writing bin/setxrd.sh … done
Writing bin/setxrd.csh … done
Writing bin/genreflex … done
Writing bin/genreflex-rootcint … done
Writing config.status … done

Enabled support for asimage, astiff, builtin_afterimage, builtin_lzma, cintex, exceptions, explicitlink, fftw3, fitsio, gviz, genvector, ldap, mathmore, memstat, mysql, opengl, python, reflex, shadowpw, shared, ssl, tmva, x11, xft, xml.

To build ROOT type:

make [/quote]

The problem appears when I try to compile a program

[quote]g++ -O -Wall -fPIC -pthread -m64 -I/home/pereira/Downloads/root/include -c test_run.cpp
g++ -O -Wall -fPIC -pthread -m64 -I/home/pereira/Downloads/root/include -L/home/pereira/Downloads/root/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic test_run.o /home/pereira/Downloads/root/lib/libPhysics.so -o test_run
/usr/bin/ld: test_run.o: undefined reference to symbol ‘TApplicationImp::Class()’
/usr/bin/ld: note: ‘TApplicationImp::Class()’ is defined in DSO /home/pereira/Downloads/root/lib/libCore.so so try adding it to the linker command line
/home/pereira/Downloads/root/lib/libCore.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [test_run] Error 1[/quote]

I can compile the same program in different machines (CentOS 64bit and Kubuntu 10.04 32bit) with ROOT 5.32 without any problem.

Any help is appreciated.
Thanks

Hi,

The ordering of libraries is important on ubuntu 11. Try comparing your link line to the content of root-config --libs and to the link line creating root.exe (to see it again do: cd $ROOTSYS; rm bin/root.exe; make)

Cheers,
Philippe.

Dear Philippe,

Thank you for your answer. At some point I’ve realized that the order of libraries in the Makefile was causing the error. I thought the responsible was the g++/gcc compiler (version 4.6.1) not Ubuntu 11. Thanks for clarifying this.

Cheers,
Sergio

input_file_1.root (72.7 KB)huga.cpp (583 Bytes)Dear Philippe,

I thought everything was fine but I was wrong. That solution worked for that particular cpp file but I guess it was just a coincidence.
I’ve followed your suggestion and compared my link line to the content of root-config --libs and to the link line creating root.exe. The outputs are the following:

$ root-config --libs

$ cd $ROOTSYS; rm bin/root.exe; make

but it didn’t work. I’ve produced the simplest example (attached cpp file) in order to reproduce the problem.
Compiling the code with the following options

[quote]g++ -O -Wall -fPIC -pthread -m64 -I/home/pereira/Downloads/root/include -c huga.cpp
g++ -O -Wall -fPIC -pthread -m64 -I/home/pereira/Downloads/root/include -o huga huga.o -L/home/pereira/Downloads/root/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic[/quote]
it compiles without any Warning or error messages but when I try to run it it crashes

[quote]$ ./huga
Warning in TClass::TClass: no dictionary for class TBranch is available
Warning in TClass::TClass: no dictionary for class TLeafI is available
Warning in TClass::TClass: no dictionary for class TLeaf is available
Warning in TClass::TClass: no dictionary for class TLeafB is available
Warning in TClass::TClass: no dictionary for class TLeafF is available
Warning in TClass::TClass: no dictionary for class TLeafS is available
Warning in TClass::TClass: no dictionary for class TVirtualIndex is available
Warning in TClass::TClass: no dictionary for class TBranchRef is available
Warning in TClass::TClass: no dictionary for class TTree is available
Error in TBufferFile::ReadClassBuffer: class: TNamed, attempting to access a wrong version: 19, object skipped at offset 54
Error in TBufferFile::CheckByteCount: object of class TNamed read too few bytes: 2 instead of 44158

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007f5f4699211e in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f5f46928e0e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f5f477f1e37 in TUnixSystem::StackTrace() () from /home/pereira/Downloads/root/lib/libCore.so
#3 0x00007f5f477f4703 in TUnixSystem::DispatchSignals(ESignals) () from /home/pereira/Downloads/root/lib/libCore.so
#4
#5 0x00007f5f47e94ac0 in typeinfo for TObject () from /home/pereira/Downloads/root/lib/libCore.so
#6 0x0000000000400efe in main ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x00007f5f47e94ac0 in typeinfo for TObject () from /home/pereira/Downloads/root/lib/libCore.so
#6 0x0000000000400efe in main ()
===========================================================[/quote]

I’ve also compiled in this way

[quote]/usr/bin/g+±4.6 -rdynamic -O2 -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude/ -pthread -m64 -I/home/pereira/Downloads/root/include huga.cpp -o huga -L/home/pereira/Downloads/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl
huga.cpp:15:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
huga.cpp:15:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
[/quote]
but it crashes in exactly the same way.

The “funny” thing is that if you uncomment the line //TTree t2; (the first line after int main()) the program works perfectly!!! This line has nothing to do with the program.
I’ve attached the two files one need to reproduce the problem (huga.cpp and input_file_1.root).

Any help will be very welcome.

All the best,
Sergio

See [url]Linking problem to libTree.so
Also, instead of manually setting all flags, try:
root-config --cxx --cflags -o huga huga.cpp root-config --glibs

[quote]The “funny” thing is that if you uncomment the line //TTree t2; (the first line after int main()) the program works perfectly!!! This line has nothing to do with the program.[/quote]This is the expected default behavior of the new Ubuntu linker (drop libraries that are not explicitly needed). In addition, you probably did not create a TApplication object (and hence did not enable the automatic library loading) in your main.

Cheers,
Philippe.

Dear Pepe Le Pew and Philippe,

Thank you for your replays. The problem was that I was not creating the TApplication object (actually the line was there but I’ve commented it).
I’ve a couple of questions (just to make it clear):

  1. I can compile it without TApplication in different machines (Mac, CentOS, previous Ubuntu distro.) and different ROOT versions (including 5.32) with different compilers. Why now I need to create the TApplication object? Is the only responsible Ubuntu 11.10?

  2. The reason why I’ve commented out that line is because I’ve a loop in my code

[quote]
char iname[80];
in_f.open(argv[1], ios::in);
while (!in_f.eof( )){
in_f.getline(iname, 80, ‘\n’);
do something;
}[/quote]

that before upgrading to Ubuntu 11 was working fine but now, with the TApplication object, the loop never ends. If I comment out the TApplication line it works.
The work around is to use the input file name explicitly instead or argv[1]. Is it also related with our previous discussion or I’m just not writing the code properly?

Thank you so much again for you help.
Sergio

[code]#include “TApplication.h”
#include

int main(int argc, char **argv) {
int itmp = (argc > 1 ? 1 : argc); // the “program’s name” at most
TApplication theApp(“App”, &itmp, argv);

for (int i = 0; i < argc; i++) {
if ( ! ((argv) && (argv[i]) ) ) break; // just a precaution
std:: cout << i << " -> " << argv[i] << std::endl;
}

return 0;
}[/code]
BTW. in my opinion, you manage “in_f” in a wrong way -> you should do:

while(1) { // http://www.cplusplus.com/reference/iostream/istream/getline/ in_f.getline(iname, sizeof(iname), '\n'); if ( ! in_f.good() ) break; // ... do something ... }

[quote] Is the only responsible Ubuntu 11.10?[/quote]Yes. Ubuntu 11.(10) has introduced new default for the linker that ignore linking requested (-lTree for example) if there is no explicit dependency on the library (i.e. you comment ‘TTree t’) and thus the ‘-lTree’ was not longer compensating for the disable autoloader.

Cheers,
Philippe.

Dear Pepe Le Pew;

Thank you for your prompt answer. Using instead of

int main(int argc, char* argv[]) {

  TApplication theApp("My First App", &argc, argv);
}

this

int main(int argc, char **argv){

  int itmp = (argc > 1 ? 1 : argc);
  TApplication theApp("App", &itmp, argv);
}

does the job. Now everything works fine.
And thanks for you advice on how I manage “in_f”. Actually, what I was doing was

while(!in_f.eof( )) {
  in_f.getline(iname, sizeof(iname), '\n');
  if(!in_f) continue;
  // ... do something ...
}

Thank you again.
All the best,
Sergio

Dear Philippe,

Thanks for your explanation. I guess I’ve a lot of things to read about this.

Cheers,
Sergio

In my opinion, that way of managing “in_f” is wrong as well.
What concerns the new Ubuntu’s linker behavior … see [url]Linking problem to libTree.so

Dear Pepe Le Pew,

I was just giving the full picture. I’ve already implemented your suggestion.

Thanks,
Sergio