# TTree problem in using Garfield++

**URL:** <https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742>\
**Category:** Garfield++\
**Created:** [November 20, 2021, 7:09am UTC](https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742 "2021-11-20T07:09:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lowerce](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lowerce/32/27228_2.png) [@Lowerce](https://root-forum.cern.ch/u/Lowerce)\
**Post date:** [November 20, 2021, 7:09am UTC](https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742/1 "2021-11-20T07:09:12Z")

</div>

In the official example of Garfield++, I can not initialize a pointer of TTree.There will be an error in the making process.  
But other parts like TCanvas 、TROOT 、TApplication of ROOT can work well.

```auto
Undefined symbols for architecture x86_64:
  "TTree::TTree(char const*, char const*, int, TDirectory*)", referenced from:
      _main in mdt.C.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mdt] Error 1

```

Above is the output message in my MacOS. In fact, I also tested it in Ubuntu 18, almost the same problem happened.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [November 20, 2021, 8:14am UTC](https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742/2 "2021-11-20T08:14:14Z")

</div>

You need to make a small modification to the `CMakeLists.txt` of your application, changing

```auto
target_link_libraries(mdt Garfield::Garfield)

```

to

```auto
target_link_libraries(mdt Garfield::Garfield ROOT::Tree)

```

---

<div class="post-metadata">

**Author:** ![Lowerce](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lowerce/32/27228_2.png) [@Lowerce](https://root-forum.cern.ch/u/Lowerce)\
**Post date:** [November 20, 2021, 2:54pm UTC](https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742/3 "2021-11-20T14:54:56Z")

</div>

Thanks a lot!  
It did solve my problem!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [December 4, 2021, 2:55pm UTC](https://root-forum.cern.ch/t/ttree-problem-in-using-garfield/47742/4 "2021-12-04T14:55:42Z")

</div>

Closed on December 4, 2021, 2:55pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
