# Compile error with TVector3

**URL:** <https://root-forum.cern.ch/t/compile-error-with-tvector3/43156>\
**Category:** Garfield++\
**Created:** [January 19, 2021, 10:57am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156 "2021-01-19T10:57:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satoko\_Asahi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/satoko_asahi/32/22156_2.png) [@Satoko\_Asahi](https://root-forum.cern.ch/u/Satoko_Asahi)\
**Post date:** [January 19, 2021, 10:57am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/1 "2021-01-19T10:57:07Z")

</div>

Hi,

I want to use a TVector3 in my Garfield++ code, but it gives me a following compile error, and I don’t know where exactly my problem comes from.

Undefined symbols for architecture x86\_64:  
“vtable for TVector3”, referenced from:  
TVector3::TVector3() in full\_tpc\_sim.C.o  
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.  
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]: \*\*\* [full\_tpc\_sim] Error 1  
make[1]: \*\*\* [CMakeFiles/full\_tpc\_sim.dir/all] Error 2  
make: \*\*\* [all] Error 2

Now I have a few basic questions:

1. I can run example codes such as AliceTPC etc. Perhaps, I get the same error when I try to use TVector3 in the AliceTPC code.  
Do I need a different makefile when I want to use a specific ROOT class in the Garfield++ code?
2. When I did a quick search of an alternative makefile, I saw a line “LIBDIR = $(GARFIELD\_HOME)/Library” in the file. Where I installed Garfield++, I don’t have a Library directory, but I see these: libGarfield.dylib, libGarfieldDict.rootmap, libGarfieldDict\_rdict.pcm. Did I install Garfiled++ correctly? or missing something else?  
I use: ROOT Version: 6.18/04, cmake version 3.16.2, gcc 4.2.1  
Any advice/suggestions would be greatly appreciated.  
Thank you in advance for your help.

Kind Regards,  
S

---

<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:** [January 19, 2021, 11:08am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/2 "2021-01-19T11:08:41Z")

</div>

Hi,  
you need to make small modification to the `CMakeLists.txt` for your application, replacing the line

```auto
target_link_libraries(full_tpc_sim Garfield)

```

by

```auto
target_link_libraries(full_tpc_sim Garfield ROOT::Physics)

```

---

<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:** [January 19, 2021, 11:09am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/3 "2021-01-19T11:09:50Z")

</div>

Regarding your second question: the makefile you found with the line `LIBDIR = $(GARFIELD_HOME)/Library` is a deprecated one, it won’t work with the CMake build of Garfield++.

---

<div class="post-metadata">

**Author:** ![Satoko\_Asahi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/satoko_asahi/32/22156_2.png) [@Satoko\_Asahi](https://root-forum.cern.ch/u/Satoko_Asahi)\
**Post date:** [January 19, 2021, 11:15am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/4 "2021-01-19T11:15:39Z")

</div>

Thank you for your quick reply! I really appreciate it.  
If I also want to use TTree, TH1F, TH2F, would it require an additional change in CMakeLists.txt?

Kind Regards,  
Satoko

---

<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:** [January 19, 2021, 11:22am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/5 "2021-01-19T11:22:56Z")

</div>

Yes, for `TTree` you need to add `ROOT::Tree` to the `target_link_libraries` command.

---

<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:** [February 2, 2021, 11:23am UTC](https://root-forum.cern.ch/t/compile-error-with-tvector3/43156/6 "2021-02-02T11:23:03Z")

</div>

Closed on February 2, 2021, 11:23am UTC

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