# TMVAClassification.C linkage error

**URL:** <https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623>\
**Category:** TMVA\
**Created:** [April 19, 2022, 12:01pm UTC](https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623 "2022-04-19T12:01:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yebondar](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/4bbf92/32.png) [@yebondar](https://root-forum.cern.ch/u/yebondar)\
**Post date:** [April 19, 2022, 12:01pm UTC](https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623/1 "2022-04-19T12:01:36Z")

</div>

I cannot compile the tutorial’s TMVAClassification.C  
After running `$(root-config --cxx --cflags) TMVAClassification.C -o tmva_class $(root-config --glibs --libs)`, I receive errors from linker:

```auto
/usr/bin/ld: /tmp/ccxpOIRE.o: in function `TMVAClassification(TString)':
TMVAClassification.C:(.text+0x2f): undefined reference to `TMVA::Tools::Instance()'
/usr/bin/ld: TMVAClassification.C:(.text+0x1074): undefined reference to `TMVA::gTools()'
...
/usr/bin/ld: TMVAClassification.C:(.text+0x3efa): undefined reference to `TMVA::Factory::EvaluateAllMethods()'
/usr/bin/ld: TMVAClassification.C:(.text+0x401c): undefined reference to `TMVA::TMVAGui(char const*, TString)'
collect2: error: ld returned 1 exit status

```

I tried different permutations the position of libs path, source code, and output, but nothing helped.

I use Root v6.26.02.Linux-ubuntu20-x86\_64-gcc9.4 ,  
Ubuntu 20.04.4 LTS on WSL2 (5.10.102.1-microsoft-standard-WSL2),  
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

---

<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:** [April 19, 2022, 12:06pm UTC](https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623/2 "2022-04-19T12:06:34Z")

</div>

Hi @yebondar ,  
what about:

```auto
$(root-config --cxx) TMVAClassification.C -o tmva_class $(root-config --libs --cflags) -lTMVA

```

(note the final `-lTMVA`)?

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![yebondar](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/4bbf92/32.png) [@yebondar](https://root-forum.cern.ch/u/yebondar)\
**Post date:** [April 19, 2022, 12:19pm UTC](https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623/3 "2022-04-19T12:19:21Z")

</div>

Hm, thanks, now better, but …

```auto
/usr/bin/ld: /tmp/ccI67ESa.o: in function `TMVAClassification(TString)':
TMVAClassification.C:(.text+0x401c): undefined reference to `TMVA::TMVAGui(char const*, TString)'
collect2: error: ld returned 1 exit status

```

NB: ACLIC runs this code well

---

<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:** [April 19, 2022, 12:30pm UTC](https://root-forum.cern.ch/t/tmvaclassification-c-linkage-error/49623/4 "2022-04-19T12:30:48Z")

</div>

You need `-lTMVAGui` as well.

> [@yebondar](#):
>
> ACLIC runs this code well

Yep, because it automagically knows which libraries to link 😃
