# Root includes could not be resolved by the Eclipse IDE Preprocessor

**URL:** <https://root-forum.cern.ch/t/root-includes-could-not-be-resolved-by-the-eclipse-ide-preprocessor/39329>\
**Category:** Newbie\
**Tags:** cmake\
**Created:** [May 8, 2020, 9:58pm UTC](https://root-forum.cern.ch/t/root-includes-could-not-be-resolved-by-the-eclipse-ide-preprocessor/39329 "2020-05-08T21:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![massimo.trifoglio](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/f9ae1b/32.png) [@massimo.trifoglio](https://root-forum.cern.ch/u/massimo.trifoglio)\
**Post date:** [May 8, 2020, 9:58pm UTC](https://root-forum.cern.ch/t/root-includes-could-not-be-resolved-by-the-eclipse-ide-preprocessor/39329/1 "2020-05-08T21:58:44Z")

</div>

I’ve created the IDE projects from the Root example “event” with the original CMakeLists.txt (see below).  
I succeeded to build and run the example. But the Preprocessor is not able to resolve the Root variables.  
Thanks a lot for any help.  
Massimo Trifoglio

\_ROOT Version: 6.16/00 installed from binaries  
\_Platform: CentoS 7.6  
\_Compiler: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)  
\_Eclipse IDE for C/C++ Developers  
Version: Oxygen.1a Release (4.7.1a) Build id: 20171005-1200

# CMakelists.txt

# CMakeLists.txt for event package. It creates a library with dictionary and a main program

cmake\_minimum\_required(VERSION 3.0 FATAL\_ERROR)  
project(event)

# You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:

# - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake

# - ROOT built with CMake. Add in CMAKE\_PREFIX\_PATH the installation prefix for ROOT

list(APPEND CMAKE\_PREFIX\_PATH $ENV{ROOTSYS})

#—Locate the ROOT package and defines a number of variables (e.g. ROOT\_INCLUDE\_DIRS)  
find\_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net)

#—Define useful ROOT functions and macros (e.g. ROOT\_GENERATE\_DICTIONARY)  
include(${ROOT\_USE\_FILE})

include\_directories({CMAKE\_SOURCE\_DIR} {ROOT\_INCLUDE\_DIRS})  
add\_definitions(${ROOT\_CXX\_FLAGS})

ROOT\_GENERATE\_DICTIONARY(G\_\_Event Event.h LINKDEF EventLinkDef.h)

#—Create a shared library with geneated dictionary  
add\_library(Event SHARED Event.cxx G\_\_Event.cxx)  
target\_link\_libraries(Event ${ROOT\_LIBRARIES})

#—Create a main program using the library  
add\_executable(Main MainEvent.cxx)  
target\_link\_libraries(Main Event)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 26, 2020, 10:49am UTC](https://root-forum.cern.ch/t/root-includes-could-not-be-resolved-by-the-eclipse-ide-preprocessor/39329/2 "2020-05-26T10:49:56Z")

</div>

Hi Massimo,  
welcome to the ROOT forum, and I’m really sorry for the late reply, this must have slipped through the cracks.

What is the error message exactly? What are the ROOT variables that the preprocessor does not resolve, and would you be able to share a link to a public git repository that reproduces the problem?

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![massimo.trifoglio](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/f9ae1b/32.png) [@massimo.trifoglio](https://root-forum.cern.ch/u/massimo.trifoglio)\
**Post date:** [May 27, 2020, 7:34pm UTC](https://root-forum.cern.ch/t/root-includes-could-not-be-resolved-by-the-eclipse-ide-preprocessor/39329/3 "2020-05-27T19:34:27Z")

</div>

Hi Enrico,  
thank you so much for your response.  
After some try with my code, I’ve tried the code in attachment. It is from CERN.  
I’ve created from it the Eclipse project. When I open the project from Eclipse all the Root variables are marked in red with the error that they cannot be resolved.

$ROOTSYS points to /usr/local/root where is installed the Root binaries version 6.16/00 for CentoS 7.x  
The .bashrc includes the following definitions:

# load Root environment

export ROOTSYS=/usr/local/root  
export PATH=$PATH:$ROOTSYS/bin  
export LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:$ROOTSYS/lib

Thanks a lot for your help.  
Cheers.  
Massimo

[event\_example.tar.gz](https://root-forum.cern.ch/uploads/short-url/dPH1hjeEt7AO0R2lrGTqFF2bj3y.gz) (10.7 KB)
