[SOLVED] How to compile ROOT with debug options?

Hello, I develop my software using Eclipse and linking against ROOT 5.20 shared libraries. Still, I cannot use the integrated debugger (gdb) to go through the ROOT code step by step or to see the values of ROOT objects. I think it is a problem of debug flags in the build procedure of ROOT. How can I set them correctly?
Or maybe I’m wrong and the real issue is not debug flags?

Thanks everyone for the help!

Hi,

One of the option to compile root in debug mode is to pass the --debug option to configure (and of course to gmake distclean to force a complete recompilation).

Cheers,
Philippe.

[quote=“pcanal”]Hi,

One of the option to compile root in debug mode is to pass the --debug option to configure (and of course to gmake distclean to force a complete recompilation).

Cheers,
Philippe.[/quote]
Thanks for the reply, but after making a distclean I tried to follow your advice and this is the result:

$ ./configure linux --disable-krb5 --debug
Configuring for linux
Invalid option '--debug'. Try ./configure --help

Where is the problem?

Hi,

My apologies for the typo, it should read:[code]./configure linux --build=debug

Thank you, the compilation with --build=debug worked indeed, but still I can’t go through the ROOT code step by step. Every time I try to inspect a ROOT object like a TString in the debugger (gdb), the debugger replies with: . Do you have any hint about this?

Hi,

Humm strange. Did you do a ‘gmake distclean’? I usually see this when portion of the code have been compiled in optimized mode. (Which compiler version are you using, and on what platform?).

Cheers,
Philippe.

I use make instead of gmake. I compile using gcc 4 on Archlinux, but my analysis code needs gcc 3.4, so the main program and the ROOT libraries are compiled with different versions of gcc. Shouldthis be the problem?
Thanks again for your suggestions and patience!

Edit: I always did a make distclean before configuring.

[quote] so the main program and the ROOT libraries are compiled with different versions of gcc. Shouldthis be the problem?[/quote]Yes this is often a source of problem (especially between 2 different major version of gcc!). I strongly recommend to compile your code and the ROOT libraries with the exact same compiler.

Cheers,
Philippe

OK, my fault. My code is not ported to gcc 4 (and the porting would be a nightmare on Earth), so is it possible to compile 5.20 with gcc 3.4? I encountered some problems, is it common or compilation with gcc 3.4 should be possible?

Hi,

v5.20 should compile with gcc 3.4.

Cheers,
Philippe.

I tried with gcc 3.4 and this configuration:

./configure linux --disable-krb5 --build=debug --enable-minuit2

from a freshly unpacked tarball (I only set gcc 3.4 and g++ 3.4 in config/Makefile.linux). I got lots of errors like this:

`.L2804' referenced in section `.rodata' of cint/cint/src/newlink.o: defined in discarded section `.gnu.linkonce.t._Z11G__convertTIlET_PK8G__value' of cint/cint/src/newlink.o

Any suggestion?
Anyway, I resolved the original problem in my own code which led me to open this thread, so I don’t need to solve this problem with ROOT urgently. Still, I’d like to have the possibility to debug step by step in the future. So if anyone has some ready advice to give me it is greatly appreciated, otherwise please don’t waste your time since I’m ok for now.

Hi,

Unless, you have a build partial compiled with another version of gcc, I see no reason for this (beside a compiler bug :frowning:).

Cheers,
Philippe.

I have two gcc compilers in my system: gcc 4 (whose executables are named gcc and g++) and gcc 3.4 (gcc-3.4 and g+±3.4). My fortran compiler is gfortran. I modified config/Makefile.linux, making the replacements gcc->gcc-3.4, g+±>g+±3.4 and g77->gfortran. I didn’t modify the compilers on any other file. Is it possible that, while Makefile.linux correctly uses gcc 3.4, some other sub-makefile defines its own compiler and uses gcc 4, namely, gcc and g++? This would result in different versions in the same code…

Hi,

Instead of fixing the Makefile, I would change PATH and LD_LIBRARY_PATH to see the g+±3.4 in front and/or use the configure option --with-cxx=, --with-f77= and --with-ld=

Cheers,
Philippe.

[quote=“pcanal”]Hi,

Instead of fixing the Makefile, I would change PATH and LD_LIBRARY_PATH to see the g+±3.4 in front and/or use the configure option --with-cxx=, --with-f77= and --with-ld=

Cheers,
Philippe.[/quote]
That didn’t work. However, I worked a bit on porting my software to gcc 4 and after a painful saturday I did it. Now, compiling everything with gcc 4 and the --build=debug option in ROOT configuration, it seems to work: I can see the values of ROOT objects in the debugging window and go through ROOT code step by step. I still have to refine many things but at least I see the light…
To recap, it seems that to avoid problems in using the debugger one has to compile everythingwith the same version of the compiler, exactly as you suggested.
Thank you very much Philippe!

For the newer build system, I guess one needs to specify
-DCMAKE_BUILD_TYPE="Debug" to get the full debug info (line numbers, etc). See Building ROOT from source - ROOT