ROOT libraries with Ubuntu 12.04 32-bit?

Hello. I compiled ROOT 5.34 from source for Ubuntu 12.04 32bits (simply used ./configure without specifying an architecture). Works fine as a standalone. However, I am having some issues when linking ROOT libraries in programs compiled using root-config. Here is the simple alias I am using in my bashrc: alias rootbuild='g++ -v root-config --cflags --glibs'
I have been using this successfully on quite a few systems before. Here is what I get when I compile a fairly simple program using a few ROOT commands (The same program compiles fine on my Mac):

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
COLLECT_GCC_OPTIONS='-v' '-pthread' '-m32' '-I' '/usr/local/root/include' '-L/usr/local/root/lib' '-pthread' '-rdynamic' '-o' 'BindingEnergies_forDavid' '-shared-libgcc' '-mtune=generic' '-march=i686'
 /usr/lib/gcc/i686-linux-gnu/4.6/cc1plus -quiet -v -I /usr/local/root/include -imultilib . -imultiarch i386-linux-gnu -D_GNU_SOURCE -D_REENTRANT BindingEnergies_forDavid.C -quiet -dumpbase BindingEnergies_forDavid.C -m32 -mtune=generic -march=i686 -auxbase BindingEnergies_forDavid -version -fstack-protector -o /tmp/cccX7sSj.s
GNU C++ (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (i686-linux-gnu)
	compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i686-linux-gnu/4.6/../../../../i686-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/root/include
 /usr/include/c++/4.6
 /usr/include/c++/4.6/i686-linux-gnu/.
 /usr/include/c++/4.6/backward
 /usr/lib/gcc/i686-linux-gnu/4.6/include
 /usr/local/include
 /usr/lib/gcc/i686-linux-gnu/4.6/include-fixed
 /usr/include/i386-linux-gnu
 /usr/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (i686-linux-gnu)
	compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2ed62271b86e2b75137544459bab1a81
COLLECT_GCC_OPTIONS='-v' '-pthread' '-m32' '-I' '/usr/local/root/include' '-L/usr/local/root/lib' '-pthread' '-rdynamic' '-o' 'BindingEnergies_forDavid' '-shared-libgcc' '-mtune=generic' '-march=i686'
 as --32 -o /tmp/ccFpZ9pm.o /tmp/cccX7sSj.s
COMPILER_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.6/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/:/lib/i386-linux-gnu/:/lib/../lib/:/usr/lib/i386-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/i686-linux-gnu/4.6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pthread' '-m32' '-I' '/usr/local/root/include' '-L/usr/local/root/lib' '-pthread' '-rdynamic' '-o' 'BindingEnergies_forDavid' '-shared-libgcc' '-mtune=generic' '-march=i686'
 /usr/lib/gcc/i686-linux-gnu/4.6/collect2 --sysroot=/ --build-id --no-add-needed --as-needed --eh-frame-hdr -m elf_i386 --hash-style=gnu -export-dynamic -dynamic-linker /lib/ld-linux.so.2 -z relro -o BindingEnergies_forDavid /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crti.o /usr/lib/gcc/i686-linux-gnu/4.6/crtbegin.o -L/usr/local/root/lib -L/usr/lib/gcc/i686-linux-gnu/4.6 -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.6/../../.. -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -ldl /tmp/ccFpZ9pm.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/i686-linux-gnu/4.6/crtend.o /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crtn.o
/tmp/ccFpZ9pm.o: In function `main':
BindingEnergies_forDavid.C:(.text+0x3b): undefined reference to `TGraph::TGraph()'
BindingEnergies_forDavid.C:(.text+0x73): undefined reference to `TGraph::TGraph()'
BindingEnergies_forDavid.C:(.text+0xab): undefined reference to `TGraph::TGraph()'
BindingEnergies_forDavid.C:(.text+0xe3): undefined reference to `TGraph::TGraph()'
BindingEnergies_forDavid.C:(.text+0x33a): undefined reference to `TFile::TFile(char const*, char const*, char const*, int)'
BindingEnergies_forDavid.C:(.text+0x441): undefined reference to `TObject::operator delete(void*)'
BindingEnergies_forDavid.C:(.text+0x44f): undefined reference to `TObject::operator delete(void*)'
BindingEnergies_forDavid.C:(.text+0x45d): undefined reference to `TObject::operator delete(void*)'
BindingEnergies_forDavid.C:(.text+0x46b): undefined reference to `TObject::operator delete(void*)'
BindingEnergies_forDavid.C:(.text+0x479): undefined reference to `TObject::operator delete(void*)'
/tmp/ccFpZ9pm.o: In function `__static_initialization_and_destruction_0(int, int)':
BindingEnergies_forDavid.C:(.text+0x50a): undefined reference to `TVersionCheck::TVersionCheck(int)'
/tmp/ccFpZ9pm.o: In function `TObject::operator new(unsigned int)':
BindingEnergies_forDavid.C:(.text._ZN7TObjectnwEj[TObject::operator new(unsigned int)]+0xd): undefined reference to `TStorage::ObjectAlloc(unsigned int)'
collect2: ld returned 1 exit status

Looks like the issue is with linking the libraries, but ROOTSYS, PATH and LD_LIBRARY_PATH seem all properly set. Because we are in 32bits, I don’t think there is an issue with libraries being at the wrong place. But it does look like a fundamental issue, since it fails to find the first ROOT object used in the program. Help would be greatly appreciated. Thanks in advance! Fred.

Try:
root-config --cxx --cflags -o MyExecutable MySourceCodeFile.cxx MyObjectFile.o root-config --glibs

It worked in a slightly different way, namely I changed my alias to:
alias rootbuild='g++ -v root-config --cflags
Then:
rootbuild -o MyExecutable MyProgram.cpp root-config --glibs
For some reason, it didn’t like the --cxx flag.
Thanks, Pepe le putois!
Cheers, Fred

Check what you get from (should be the name of the C++ compiler that was used to build ROOT):
root-config --cxx

[quote]For some reason, it didn’t like the --cxx flag.[/quote]Actually the real issue is the location of the libraries on the link line. In the first version the graphics library where at the beginning while in the second one they are at the end. In newer version of the linker, the linker only does one pass over the library (so when the library are on the left of the command line, they are not used since there is nothing before them that need them … and they are not used to resolve the symbol for .o that come later on the command line).

Cheers,
Philippe.

Yes, it’s clear that the “order” was the problem.
I just wonder what “root-config --cxx” returns and why it doesn’t return “g++” (or “clang”?).