I want to build a c++ projection using root library, the code below:
#include <iostream>
#include <TApplication.h>
int main()
{
std::cout<<"hello world!"<<std::endl;
return 100000000;
}
when compiling the projection, the error occurs:
home/llh/root/TGeometry/SimpleFissionChamber/SFC.C:4:10: fatal error: TApplication.h: 没有那个文件或目录
4 | #include <TApplication.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
anything else i shauld do to use root library?
Please read tips for efficient and successful posting and posting code _
ROOT Version: 6.22/06
Platform: ubuntu 20.04
Compiler: GCC 9.3.0
couet
February 8, 2021, 5:43am
2
What is exactly the fatal error you get ? file not found ?
yes, TApplication.h file can not be found,
i think: maybe the GCC can not compile the root code, but the root compiler can make c++ code.
couet
February 8, 2021, 6:01am
4
is the variable ROOTSYS
defined ?
yes,
root@llh-virtual-machine:~# echo $ROOTSYS
/usr/local/root/root
root@llh-virtual-machine:~#
couet
February 9, 2021, 7:42am
6
Have you “sourced” the script thisroot.sh
from the $ROOTSYS/bin/
directory ?
yes, my root program works well.
maybe the root configuration environment is wrong in CMakeLists.txt file,
when revised the CMakeLists.txt file, the code works well.
couet
February 9, 2021, 9:32am
8
I am not sure what’s wrong then. May be @oshadura has an idea.
Can you please share your CMakeLists.txt file?
Here is an example of how to integrate ROOT in your CMake project: Integrating ROOT into CMake projects - ROOT
Yup, looks like a missing target_include_directories
or similar in the CMakeLists.txt.
CMakeLists.txt (438 Bytes)
when i use this CMakeLists.txt file, everything works well.
thanks all!
1 Like
system
Closed
February 24, 2021, 1:18am
12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.