Root includes could not be resolved by the Eclipse IDE Preprocessor

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)

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

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 (10.7 KB)