# Error in Adding TGraph. h to cpp file

**URL:** <https://root-forum.cern.ch/t/error-in-adding-tgraph-h-to-cpp-file/57170>\
**Category:** Newbie\
**Created:** [November 20, 2023, 9:42am UTC](https://root-forum.cern.ch/t/error-in-adding-tgraph-h-to-cpp-file/57170 "2023-11-20T09:42:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harriet\_Kumi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/harriet_kumi/32/31605_2.png) [@Harriet\_Kumi](https://root-forum.cern.ch/u/Harriet_Kumi)\
**Post date:** [November 20, 2023, 9:42am UTC](https://root-forum.cern.ch/t/error-in-adding-tgraph-h-to-cpp-file/57170/1 "2023-11-20T09:42:49Z")

</div>

Good morning,

Please, I have a cmake folder that I have built and installed. I included root in my CMAKELISTS.txt. After building my folder, I had an error with the make -j4. I think that the error relates to me adding TGraph.h to my main.cpp file because if I remove TGraph.h, I do not get the error. This is the error I get:

‘’’  
harriet@harriet-ROG-Zephyrus-G15-GA503RM-GA503RM:~/kalman filter/OpenKF/build$ make -j4  
[14%] Built target OpenKF  
[28%] Built target example\_\_kf\_state\_estimation  
[42%] Built target example\_\_unscented\_transform  
[57%] Built target example\_\_ekf\_range\_sensor  
[64%] Building CXX object Examples/ukf\_range\_sensor/CMakeFiles/example\_\_ukf\_range\_sensor.dir/main.cpp.o  
[92%] Built target example\_\_test\_least\_squares  
[92%] Built target example\_\_sr\_ukf\_linear\_function  
In file included from /home/harriet/root/root-6.28.04/root-install/include/ROOT/RConfig.hxx:23,  
from /home/harriet/root/root-6.28.04/root-install/include/RtypesCore.h:23,  
from /home/harriet/root/root-6.28.04/root-install/include/TMathBase.h:29,  
from /home/harriet/root/root-6.28.04/root-install/include/TMath.h:15,  
from /home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:16:  
/home/harriet/root/root-6.28.04/root-install/include/RConfigure.h:30:4: warning: #warning “The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues” [-Wcpp]  
30 | # warning “The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues”  
| ^ ~~~~~~  
In file included from /home/harriet/root/root-6.28.04/root-install/include/TString.h:29,  
from /home/harriet/root/root-6.28.04/root-install/include/TNamed.h:26,  
from /home/harriet/root/root-6.28.04/root-install/include/TGraph.h:24,  
from /home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:22:  
/home/harriet/root/root-6.28.04/root-install/include/ROOT/RStringView.hxx:90:17: error: expected type-specifier  
90 | operator std::string\_view() const { return std::string\_view(fData,fLength); }  
| ^~~  
In file included from /home/harriet/root/root-6.28.04/root-install/include/TNamed.h:26,  
from /home/harriet/root/root-6.28.04/root-install/include/TGraph.h:24,  
from /home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:22:  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:118:13: error: expected type-specifier  
118 | operator std::string\_view() const { return std::string\_view(Data(),fExtent); }  
| ^~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:291:32: error: ‘string\_view’ in namespace ‘std’ does not name a type  
291 | explicit TString(const std::string\_view &sub);  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:291:27: note: ‘std::string\_view’ is only available from C++17 onwards  
291 | explicit TString(const std::string\_view &sub);  
| ^~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:328:37: error: ‘string\_view’ in namespace ‘std’ does not name a type  
328 | TString &operator=(const std::string\_view &s);  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:328:32: note: ‘std::string\_view’ is only available from C++17 onwards  
328 | TString &operator=(const std::string\_view &s);  
| ^~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:456:9: error: ‘string\_view’ in namespace ‘std’ does not name a type  
456 | std::string\_view View() const { return std::string\_view(GetPointer(),Length()); }  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:456:4: note: ‘std::string\_view’ is only available from C++17 onwards  
456 | std::string\_view View() const { return std::string\_view(GetPointer(),Length()); }  
| ^~~  
In file included from /home/harriet/root/root-6.28.04/root-install/include/TNamed.h:26,  
from /home/harriet/root/root-6.28.04/root-install/include/TGraph.h:24,  
from /home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:22:  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:851:53: error: ‘string\_view’ in namespace ‘std’ does not name a type  
851 | inline Bool\_t operator==(const char \*s1, const std::string\_view &s2)  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:851:48: note: ‘std::string\_view’ is only available from C++17 onwards  
851 | inline Bool\_t operator==(const char _s1, const std::string\_view &s2)  
| ^~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:851:15: error: ‘Bool\_t operator==(const char_, const int&)’ must have an argument of class or enumerated type  
851 | inline Bool\_t operator==(const char _s1, const std::string\_view &s2)  
| ^ ~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:856:37: error: ‘string\_view’ in namespace ‘std’ does not name a type  
856 | inline Bool\_t operator==(const std::string\_view &s1, const char s2)  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:856:32: note: ‘std::string\_view’ is only available from C++17 onwards  
856 | inline Bool\_t operator==(const std::string\_view &s1, const char s2)  
| ^~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:856:15: error: ‘Bool\_t operator==(const int&, const char)’ must have an argument of class or enumerated type  
856 | inline Bool\_t operator==(const std::string\_view &s1, const char s2)  
| ^ ~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:869:37: error: ‘string\_view’ in namespace ‘std’ does not name a type  
869 | std::string printValue(const std::string\_view val);  
| ^ ~~~~~~~~~~  
/home/harriet/root/root-6.28.04/root-install/include/TString.h:869:32: note: ‘std::string\_view’ is only available from C++17 onwards  
869 | std::string printValue(const std::string\_view val);  
| ^~~  
/home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp: In function ‘void energyloss(std::string, TGraph_)’:  
/home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:60:20: error: aggregate ‘std::ifstream elossfile’ has incomplete type and cannot be defined  
60 | std::ifstream elossfile;  
| ^ ~~~~~~~~  
/home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:68:40: error: ‘ios’ has not been declared  
68 | elossfile.open(eLossFileName\_,ios::in);  
| ^~~  
/home/harriet/kalman filter/OpenKF/Examples/ukf\_range\_sensor/main.cpp:69:50: error: ‘std::ifstream::traits\_type’ has not been declared  
69 | if ((elossfile.peek() == std::ifstream::traits\_type::eof())) {  
| ^ ~~~~~~~~~~  
make[2]: \*\*\* [Examples/ukf\_range\_sensor/CMakeFiles/example\_\_ukf\_range\_sensor.dir/build.make:76: Examples/ukf\_range\_sensor/CMakeFiles/example\_\_ukf\_range\_sensor.dir/main.cpp.o] Error 1  
make[1]: \*\*\* [CMakeFiles/Makefile2:325: Examples/ukf\_range\_sensor/CMakeFiles/example\_\_ukf\_range\_sensor.dir/all] Error 2  
make: \*\*\* [Makefile:136: all] Error 2

‘’’

these are my:  
\_ROOT Version: root\_v6.28.04.source.tar.gz

\_Platform:Ubuntu 22.04.3 LTS  
\_Compiler: c++

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [November 20, 2023, 11:08am UTC](https://root-forum.cern.ch/t/error-in-adding-tgraph-h-to-cpp-file/57170/2 "2023-11-20T11:08:07Z")

</div>

Hi,

It seems to me that your are building with a too low C++ version. ROOT now requires C+±17, see this message you are having:

`# warning “The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues”`

You should add in your CMake file the requirement to have C+±17, by adding for example this line:

```auto
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![Harriet\_Kumi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/harriet_kumi/32/31605_2.png) [@Harriet\_Kumi](https://root-forum.cern.ch/u/Harriet_Kumi)\
**Post date:** [November 20, 2023, 11:40am UTC](https://root-forum.cern.ch/t/error-in-adding-tgraph-h-to-cpp-file/57170/3 "2023-11-20T11:40:19Z")

</div>

Thank you very much it worked.
