Hi,
When I use CMake to compile a C++ program that using ROOT library.I’m in a trouble.
The directory structure of this program like this :
├── build
├── CMakeLists.txt
├── include
│ └── Recoil_Energy_Spectrum.hh
└── src
├── CMakeLists.txt
└── Recoil_Energy_Spectrum.cc
The contents of CMakeLists.txt in PROJECT_SOURCE_DIR:
add_executable(Recoil_Energy_Spectrum Recoil_Energy_Spectrum.cc)
target_link_directories(Recoil_Energy_Spectrum PUBLIC ${ROOT_LIBRARIES})
When I compile this program,the compiler said it could’t link to ROOT libraries.How to solve this problem?
Thanks. ROOT Version: 6.20/02 Platform: Linux Compiler: GNU 8.3.0
Thanks for reply.But the compiler still gives errors like this:Recoil_Energy_Spectrum.cc:(.text+0x2a4): undefined reference to `TFile::Open(char const*, char const*, char const*, int, int)’