# Using cmake to include root package

**URL:** <https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915>\
**Category:** Newbie\
**Created:** [February 10, 2020, 2:09pm UTC](https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915 "2020-02-10T14:09:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![penielse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@penielse](https://root-forum.cern.ch/u/penielse)\
**Post date:** [February 10, 2020, 2:09pm UTC](https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915/1 "2020-02-10T14:09:24Z")

</div>

Hi  
I have a small cpp program, in which I would like to use the TVector package from root. I have root installed on my pc. I am running Ubuntu.  
I use cmake to generate my makefile. I know that somehow need to link to the TVector package in the make file, to be able to include:  
#include “TVector.h”  
in the cpp code. How do I do that?

The process described here  
[https://root.cern.ch/how/integrate-root-my-project-cmake](https://root.cern.ch/how/integrate-root-my-project-cmake)  
is too technical for me. I have tried copy/pasting it into my CMakeLists.txt file, but it did not work.

Hope you can help

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [February 11, 2020, 11:12am UTC](https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915/2 "2020-02-11T11:12:17Z")

</div>

Can you paste please your current working CMakeLists.txt?

---

<div class="post-metadata">

**Author:** ![penielse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@penielse](https://root-forum.cern.ch/u/penielse)\
**Post date:** [February 11, 2020, 11:40am UTC](https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915/3 "2020-02-11T11:40:30Z")

</div>

A colleague fixed the problem for me. If anyone else will have the same issue, the makefile is here:

#Add this path and root’s path includes  
CXXFLAGS = -I./(INCDIR) -I(shell root-config --incdir)  
#Set optimisation and use C++ version from root (C++11 on lxplus)  
CXXFLAGS +=-O2 -g -Wall $(shell root-config --cflags)

ROOTLIBS := (shell root-config --libs) -Wl,-rpath,(ROOTSYS)/lib

all: MySim.exe

clean:  
-rm -f \*.o MySim.exe

MySim.exe: %.exe:  
(CXX) MySIm.cpp -o @ (MACHFLAG) (LDFLAGS) (CXXFLAGS) ^ (MIDASLIBS) (ROOTLIBS) -lm -lz -lutil -lpthread

---

<div class="post-metadata">

**Author:** ![penielse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@penielse](https://root-forum.cern.ch/u/penielse)\
**Post date:** [February 12, 2020, 12:17pm UTC](https://root-forum.cern.ch/t/using-cmake-to-include-root-package/37915/4 "2020-02-12T12:17:19Z")

</div>

Actually, if someone could help me translate this makefile to a CMakeLists.txt, I would be grateful!
