How to fix ROOT ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Problem
When running a ROOT program, you see an error message such as
ERROR in cling::CIFactory::createCI(): cannot extract standard library include paths!
Invoking:
LC_ALL=C x86_64-linux-gnu-g++-7 -xc++ -E -v /dev/null 2>&1 | sed -n -e '/^.include/,${' -e '/^ \/.*++/p' -e '}'
Results was:
With exit code 0
Solution
In general, this means that you’ve used the wrong version of ROOT for your operating system or compiler. The easiest solution is therefore to download a suitable version of ROOT for your operating systemx86_64-linux-gnu-g++-7 If that isn’t possible, the correct solution is to build ROOT from source. This way, you can ensure that ROOT is built with the correct compiler and settings for your system. See Building ROOT from source for more instructions.
In case that doesn’t work either - typically due to some uncommon compiler or operating system - you can try the hack that worked for me:
First, run the command with the normal g++
compiler:
g++ -xc++ -E -v /dev/null 2>&1 | sed -n -e '/^.include/,${' -e '/^ \/.*++/p' -e '}'
It should produce at least one line of output such as:
/usr/include/c++/7
/usr/include/c++/7/x86_64-suse-linux
/usr/include/c++/7/backward
If that works, you can give root the compiler name it expects by creating a symlink from g++
to x86_64-linux-gnu-g++-7
. Remember to copy the name of the compiler from the error message, as it may differ on your system or for your ROOT version.
You need to place that symlink in some directory accessible on PATH. If you have sudo
access, use /usr/local/bin
, if not, I recommend $HOME/usr/bin
(but you need to add that to your PATH).
ln -s $(which g++) $HOME/usr/bin/x86_64-linux-gnu-g++-7
After that, ROOT will be able to find the fake compiler and should work correctly.