# Classdef

**URL:** <https://root-forum.cern.ch/t/classdef/22337>\
**Category:** ROOT\
**Created:** [December 8, 2016, 8:23pm UTC](https://root-forum.cern.ch/t/classdef/22337 "2016-12-08T20:23:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mato](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mato/32/12317_2.png) [@mato](https://root-forum.cern.ch/u/mato)\
**Post date:** [December 12, 2016, 8:28am UTC](https://root-forum.cern.ch/t/classdef/22337/5 "2016-12-12T08:28:41Z")

</div>

As Philippe pointed out, you need to link against the generated dictionary of our class. Just changing slightly the CMakeLists.txt file like this should work.

```auto
cmake_minimum_required(VERSION 2.8)

project(tbjcAnalysis)

list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT)
include(${ROOT_USE_FILE})

include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})

include_directories(${PROJECT_SOURCE_DIR}/include)
ROOT_GENERATE_DICTIONARY(G__test include/test.h)

file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cxx)
add_executable(example main.cxx G__test.cxx ${sources})
target_link_libraries(example ${ROOT_LIBRARIES})

```

Notice the following changes:

- Use the CMAKE\_PREFIX\_PATH to tell where to find the ROOTConfig.cmake file instead of using FindROOT.cmake (if ROOT was build with CMake).
- Use the file ${ROOT\_USE\_FILE} to define useful macros (i.e. ROOT\_GENERATE\_DICTIONARY)
- Generation of the dictionary G\_\_test.cxx and its use to build the executable example.

Cheers,  
Pere

---

_[View the full topic](https://root-forum.cern.ch/t/classdef/22337)._
