# CMake File issue

**URL:** <https://root-forum.cern.ch/t/cmake-file-issue/51148>\
**Category:** Newbie\
**Created:** [August 10, 2022, 7:02pm UTC](https://root-forum.cern.ch/t/cmake-file-issue/51148 "2022-08-10T19:02:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhinab\_Mukhopadhyay](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abhinab_mukhopadhyay/32/20444_2.png) [@Abhinab\_Mukhopadhyay](https://root-forum.cern.ch/u/Abhinab_Mukhopadhyay)\
**Post date:** [August 10, 2022, 7:02pm UTC](https://root-forum.cern.ch/t/cmake-file-issue/51148/1 "2022-08-10T19:02:10Z")

</div>

Hi, I am running a GEANT4 program that calls upon ROOT files and headers. In the cmake file I have included ROOT directories :

```auto
# Locate sources and headers for this project
#
include_directories(${PROJECT_SOURCE_DIR}/include
                    ${Geant4_INCLUDE_DIR}
	            ${ROOT_INCLUDE_DIRS})  		
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)

```

However, when I run the CMake file I run into these errors :

```auto
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/ActionInitialization.cc.o: in function `_GLOBAL__sub_I_ActionInitialization.cc':
ActionInitialization.cc:(.text.startup+0x44): undefined reference to `TVersionCheck::TVersionCheck(int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `EventAction::EventAction(RunAction*)':
EventAction.cc:(.text+0x229): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
/usr/bin/ld: EventAction.cc:(.text+0x24f): undefined reference to `TFile::TFile(char const*, char const*, char const*, int)'
/usr/bin/ld: EventAction.cc:(.text+0x258): undefined reference to `TDirectory::CurrentDirectory()'
/usr/bin/ld: EventAction.cc:(.text+0x265): undefined reference to `TStorage::ObjectAlloc(unsigned long)'
/usr/bin/ld: EventAction.cc:(.text+0x286): undefined reference to `TTree::TTree(char const*, char const*, int, TDirectory*)'
/usr/bin/ld: EventAction.cc:(.text+0x2aa): undefined reference to `TTree::Branch(char const*, void*, char const*, int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `_GLOBAL__sub_I_EventAction.cc':
EventAction.cc:(.text.startup+0x38): undefined reference to `TVersionCheck::TVersionCheck(int)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/EventAction.cc.o: in function `EventAction::EventAction(RunAction*) [clone .cold]':
EventAction.cc:(.text.unlikely+0x4): undefined reference to `TObject::operator delete(void*)'
/usr/bin/ld: EventAction.cc:(.text.unlikely+0x1c): undefined reference to `TObject::operator delete(void*)'
/usr/bin/ld: CMakeFiles/FCP_Simulation.dir/src/SteppingAction.cc.o: in function `_GLOBAL__sub_I_SteppingAction.cc':
SteppingAction.cc:(.text.startup+0x38): undefined reference to `TVersionCheck::TVersionCheck(int)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/FCP_Simulation.dir/build.make:400: FCP_Simulation] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/FCP_Simulation.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

```

I included the ROOT Libraries so I don’t know why I am getting the errors.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 10, 2022, 7:21pm UTC](https://root-forum.cern.ch/t/cmake-file-issue/51148/2 "2022-08-10T19:21:09Z")

</div>

The error says the linker is missing ROOT libraries (so it’s not about ROOT includes).

---

<div class="post-metadata">

**Author:** ![Abhinab\_Mukhopadhyay](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abhinab_mukhopadhyay/32/20444_2.png) [@Abhinab\_Mukhopadhyay](https://root-forum.cern.ch/u/Abhinab_Mukhopadhyay)\
**Post date:** [August 10, 2022, 7:59pm UTC](https://root-forum.cern.ch/t/cmake-file-issue/51148/3 "2022-08-10T19:59:19Z")

</div>

Hi, thank you, how would I go about in including ROOT Libraries?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 10, 2022, 8:36pm UTC](https://root-forum.cern.ch/t/cmake-file-issue/51148/4 "2022-08-10T20:36:03Z")

</div>

[Geant4 → User Forum](https://geant4-forum.web.cern.ch/)

E.g.:

> **[Include Root header to Geant4 error: Undefined symbols for architecture x86\_64:...](https://geant4-forum.web.cern.ch/t/include-root-header-to-geant4-error-undefined-symbols-for-architecture-x86-64-tversioncheck-tversioncheck-int/2514/2)**
>
> The error you see is clang: error: linker command failed with exit code 1 which means you did not link against the libraries of ROOT (you only included the header files). Change this line: target\_link\_libraries(exampleB1 ${Geant4\_LIBRARIES}...
