How to use c++17 with root

Hi all,
I am working on Lxplus, trying to use “for_each” to do some parallel calculations wih c++17.
But the root can not load the head “execution”. Below is a test:

#include<execution>
#include<iostream>
#include<execution>
using namespace std;
int test(){
    cout<<123<<endl;
    return 1;
}

The error is

 strong/Run/test.cpp:9:9: 
fatal error: 'execution' file not found

Do you have any idea about this problem? Thank you very much!


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi @11111 ,
you need a ROOT installation that was built for C++17. You can check which standard ROOT was built with e.g. with root-config --cflags.

On LXPLUS, you can grab one such build from the LCG releases, e.g.:

[eguiraud@lxplus716 ~]$ source /cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos7-gcc11-opt/setup.sh
[eguiraud@lxplus716 ~]$ which root && root-config --cflags
/cvmfs/sft.cern.ch/lcg/views/LCG_101/x86_64-centos7-gcc11-opt/bin/root
-pthread -std=c++17 -m64 -I/cvmfs/sft.cern.ch/lcg/releases/ROOT/6.24.06-3455f/x86_64-centos7-gcc11-opt/include

Cheers,
Enrico

1 Like

Hi Enrico,
Yes, It works. Thank you very much!

Cheers,
Xin

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