Problem linking root libraries with g++-4.6 compiler

Dear experts,

I work with Ubuntu 11.10.
The default compiler is g+±4.6
I installed root_v5.32.00 by compiling the source with g+±4.6 with no problem.

Here is the configure command I used:
./configure linuxx8664gcc --with-x11-libdir=/usr/lib/x86_64-linux-gnu/
–with-xft-libdir=/usr/lib/x86_64-linux-gnu/ --with-xext-libdir=/usr/lib/x86_64-linux-gnu/

config.log file in attachment.

I run “source /bin/thisroot.sh” to define the necessary environment variables for binaries and libraries:
gianluca@vip09:~ source MySoftware/root_v5.32.00/bin/thisroot.sh gianluca@vip09:~ env | grep root
MANPATH=/home/gianluca/MySoftware/root_v5.32.00/man:/usr/local/man:/usr/local/share/man:/usr/share/man
LD_LIBRARY_PATH=/home/gianluca/MySoftware/root_v5.32.00/lib
LIBPATH=/home/gianluca/MySoftware/root_v5.32.00/lib
PATH=/home/gianluca/MySoftware/root_v5.32.00/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
ROOTSYS=/home/gianluca/MySoftware/root_v5.32.00
DYLD_LIBRARY_PATH=/home/gianluca/MySoftware/root_v5.32.00/lib
PYTHONPATH=/home/gianluca/MySoftware/root_v5.32.00/lib
SHLIB_PATH=/home/gianluca/MySoftware/root_v5.32.00/lib

/bin/root works perfectly, CINT show no problem when I compile from terminal
.L src/CreateSimpleEventTree.cxx+

same code fails to compile with g+±4.6

/usr/bin/g+±4.6 -L/home/gianluca/MySoftware/root_v5.32.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -O2 -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude/ -pthread -m64 -I/home/gianluca/MySoftware/root_v5.32.00/include src/CreateSimpleEventTree.cxx -o bin/CreateSimpleEventTree
/tmp/ccQeRVWy.o: In function main': CreateSimpleEventTree.cxx:(.text.startup+0x21): undefined reference to TString::TString(char const*)’
CreateSimpleEventTree.cxx:(.text.startup+0x41): undefined reference to operator<<(std::basic_ostream<char, std::char_traits<char> >&, TString const&)' CreateSimpleEventTree.cxx:(.text.startup+0x53): undefined reference to TString::~TString()’
CreateSimpleEventTree.cxx:(.text.startup+0x7e): undefined reference to `TString::~TString()’
collect2: ld returned 1 exit status

but g+±4.4 is successful
/usr/bin/g+±4.4 -L/home/gianluca/MySoftware/root_v5.32.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -O2 -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude/ -pthread -m64 -I/home/gianluca/MySoftware/root_v5.32.00/include src/CreateSimpleEventTree.cxx -o bin/CreateSimpleEventTree
CreateSimpleEventTree compiled.
all done!

What am I doing wrong?

Thanks for helping out.

gianluca
config.txt (219 KB)

Hi,

The problem is the order of the libraries on the link line. How is it determined in your case (i.e. did you use root-config --libs)?

Philippe.

Hi Philippe,

yes I used the following command:

root-config --libs
-L/home/gianluca/MySoftware/root_v5.32.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic

Hi,

Try listing the source file before the library (i.e. something lie:/usr/bin/g++-4.6 -rdynamic -O2 -pipe -m64 -Wshadow -Wall -W -Woverloaded-virtual -fPIC -Iinclude/ -pthread -m64 -I/home/gianluca/MySoftware/root_v5.32.00/include src/CreateSimpleEventTree.cxx -o bin/CreateSimpleEventTree -L/home/gianluca/MySoftware/root_v5.32.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl

Cheers,
Philippe.

Hi Philippe,

thank you very much, placing the root library after the source made it work with g+±4.6.

/usr/bin/g++-4.6 -Iinclude/ -pthread -m64 -I/home/gianluca/MySoftware/root_v5.32.00/include src/CreateSimpleEventTree.cxx tmp/MyDict.o tmp/MyEventClass.o -o bin/CreateSimpleEventTree -L/home/gianluca/MySoftware/root_v5.32.00/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic CreateSimpleEventTree compiled. all done!

anyway… why is that? what’s the difference with g+±4.4?

Thank you again

gianluca

Hi,

They have updated the linking rules to make same (intentionally) more stringent (and respect ordering 'more).

Cheers,
Philippe.

Ah, that makes sense.

OK, thanks for the information, and many thanks for helping out.

Best,

Gianluca