How to install ROOT 6.08.06 using gcc (version 8.3) different than the default gcc (version 4.8)


ROOT Version: 6.08.06
Platform: Scientific Linux
Compiler: g+±8.3


Hello all,

I am configuring my ROOT with the following command,
./configure --with-cc=g+±8.2 --with-cxx=g+±8.2 --cxxflags=’-fPIC -O3 -std=c++11’ --with-ld=g+±8.2 --enable-cxx14 --with-gcc-toolchain=/home/wpol/GCC_8_3_0/Install/
Then, during the ‘make’ command, after 9% errors are encountered whose first 4-5 lines I am copying it here,

[ 9%] Linking CXX executable …/…/bin/llvm-tblgen
CMakeFiles/obj.llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o: In function SimplifyTree(llvm::TreePatternNode*&)': CodeGenDAGPatterns.cpp:(.text._ZL12SimplifyTreeRPN4llvm15TreePatternNodeE+0x47): undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(char const*) const’
CMakeFiles/obj.llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o: In function void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .constprop.917]': CodeGenDAGPatterns.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag.constprop.917+0x6b): undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned long)’
CMakeFiles/obj.llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o: In function void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) [clone .constprop.918]': CodeGenDAGPatterns.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag.constprop.918+0x6b): undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned long)’

Please suggest how to resolve this matter.

Thank you,
Shaptak

First, you should use CMake instead of "configure"as written here. Maybe, it will help you to solve this issue. I cannot say too much because usually I only use one compiler version to avoid compiling issue. So you should add the path to your gcc8 in your $PATH. The same for $LD_LIBRARY_PATH and try to compile again.

Thanks for the suggestion.
But, while using CMake , how will I make sure that it will use the gcc that I specify and not the default one ?

Export CXX=gcc-8 (which gcc output) maybe is enough, run cmake…/ and then check the ccmake…/ dialog window. Hope it helps

Hi ,
I did what you suggested, i.e. export cxx. But still cmake is taking the default cxx compiler. Can you suggest any other way to do ?

Have you removed the cache of cmake previously produced?

I have deleted the whole folder that I have created for building the root and then made the new folder & re-run the cmake command with export cxx prior to it. Will it be equivalent of clearing the cmake cache ?

Yes it is the same.
But have you tried at all https://stackoverflow.com/questions/17275348/how-to-specify-new-gcc-path-for-cmake to do as said here? Maybe is the CC to update not CXX. In general I always do like this to avoid cmake projects to pick up a system default but specifying the compiler.

Yeah, I did this thing :

export CXX=/usr/local/bin/g++
cmake /path/to/your/project

But this thing: CXX=g+±8.2 cmake …/root-6.08.06/ actually worked.
However, I came across a new error

CMakeFiles/root.dir/src/rootx.cxx.o: In function main': /home/wpol/codes/root-6.08.06/rootx/src/rootx.cxx:605: undefined reference to__cxa_throw_bad_array_new_length’
CMakeFiles/root.dir/src/rootx.cxx.o: In function bool std::operator==<char, std::char_traits<char>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)': /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:6084: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare(char const*) const’
CMakeFiles/root.dir/src/rootx.cxx.o: In function std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(char const*)': /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:704: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::assign(char const*)’
CMakeFiles/root.dir/src/rootx.cxx.o: In function GetExePath': /home/wpol/codes/root-6.08.06/rootx/src/rootx.cxx:224: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string()’
CMakeFiles/root.dir/src/rootxx.cxx.o: In function std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(unsigned long, char, std::allocator<char> const&)': /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:531: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct(unsigned long, char)’
CMakeFiles/root.dir/src/rootxx.cxx.o: In function std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*)': /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1439: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)’
CMakeFiles/root.dir/src/rootxx.cxx.o: In function std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*)': /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1268: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_append(char const*, unsigned long)’
/home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1268: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' CMakeFiles/root.dir/src/rootxx.cxx.o: In functionstd::__cxx11::basic_string<char, std::char_traits, std::allocator >::assign(char const*)’:
/home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1439: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)' CMakeFiles/root.dir/src/rootxx.cxx.o: In functionstd::__cxx11::basic_string<char, std::char_traits, std::allocator >::append(char const*)’:
/home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1268: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' /home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1268: undefined reference tostd::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_append(char const*, unsigned long)’
/home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.h:1268: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)' CMakeFiles/root.dir/src/rootxx.cxx.o: In functionvoid std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)’:
/home/wpol/GCC_8_3_0/Install/include/c++/8.3.0/bits/basic_string.tcc:219: undefined reference to `std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_create(unsigned long&, unsigned long)’
collect2: error: ld returned 1 exit status
gmake[2]: *** [bin/root] Error 1
gmake[1]: *** [rootx/CMakeFiles/root.dir/all] Error 2

Any suggestion, please

Granted I am not an expert, but this type of errors happens when you miss or set a different support for c++ versions. I let other experts to comment but you may try opening the cmake window and check the c++ standards you are using. BTW do you also have g+±8?) it may be you just have to export CXX and C as in the stackoverflow channel I gave you before. In any cases, as root depends on some other installed code in your laptop, if the other libraries are not compiled with Gcc8 you may have issues.

To use a specific compiler, call cmake as

cmake /path/to/root -DCMAKE_C_COMPILER=/path/to/gcc-8 -DCMAKE_CXX_COMPILER=/path/to/g++-8 [other options]...

I also really recommend moving to ROOT 6.16 if you can. There were lots of fixes for GCC8 that are only in the latest versions.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.