# Compilation error for TMVA Reader() and Instances()

**URL:** <https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195>\
**Category:** TMVA\
**Tags:** root\
**Created:** [January 20, 2023, 5:32pm UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195 "2023-01-20T17:32:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nihar\_Saha](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nihar_saha/32/19673_2.png) [@Nihar\_Saha](https://root-forum.cern.ch/u/Nihar_Saha)\
**Post date:** [January 20, 2023, 5:32pm UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195/1 "2023-01-20T17:32:45Z")

</div>

Dear experts,

While I was compiling my c++ code (hist\_mass\_vn.C) with the following command it is showing me some errors mentioned below. In my code, I am using the TMVA Reader() and the .xml files that are produced after BDT training because of that it is showing an error. I tried with multiple options available for compilation but nothing worked in my case. I will appreciate any kind of help on this.

Compilation command I am using:  
`g++ -o vn.out hist_mass_vn.C `root-config --cflags --glibs`

Error I am getting:

```auto
/tmp/nsaha/ccmMt5bV.o: In function `hist_mass_vn(int)':

hist_mass_vn.C:(.text+0x1a60): undefined reference to `TMVA::Tools::Instance()'

hist_mass_vn.C:(.text+0x1aa1): undefined reference to `TMVA::Reader::Reader(TString const&, bool)'

hist_mass_vn.C:(.text+0x1b0d): undefined reference to `TMVA::Reader::AddVariable(TString const&, float*)'

hist_mass_vn.C:(.text+0x1b56): undefined reference to `TMVA::Reader::AddVariable(TString const&, float*)'

hist_mass_vn.C:(.text+0x1b9f): undefined reference to `TMVA::Reader::AddVariable(TString const&, float*)'

hist_mass_vn.C:(.text+0x1be8): undefined reference to `TMVA::Reader::AddVariable(TString const&, float*)'

hist_mass_vn.C:(.text+0x1c31): undefined reference to `TMVA::Reader::AddVariable(TString const&, float*)'

/tmp/nsaha/ccmMt5bV.o:hist_mass_vn.C:(.text+0x1c7a): more undefined references to `TMVA::Reader::AddVariable(TString const&, float*)' follow

/tmp/nsaha/ccmMt5bV.o: In function `hist_mass_vn(int)':

hist_mass_vn.C:(.text+0x1d40): undefined reference to `TMVA::Reader::BookMVA(TString const&, TString const&)'

hist_mass_vn.C:(.text+0x2508): undefined reference to `TMVA::Reader::EvaluateMVA(TString const&, double)'

collect2: error: ld returned 1 exit status

```

Thanks & regards,  
Nihar

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 20, 2023, 8:09pm UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195/2 "2023-01-20T20:09:28Z")

</div>

Add: `-lTMVA`

---

<div class="post-metadata">

**Author:** ![Nihar\_Saha](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nihar_saha/32/19673_2.png) [@Nihar\_Saha](https://root-forum.cern.ch/u/Nihar_Saha)\
**Post date:** [January 21, 2023, 5:37am UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195/3 "2023-01-21T05:37:55Z")

</div>

You mean: g++ -o vn.out hist\_mass\_vn.C `root-config --cflags --glibs -lTMVA`

Please correct me if I am wrong!

Still I’m getting error:

```auto
Unknown argument "-lTMVA"!

Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--auxcflags] [--ldflags] [--new] [--nonew] [--libs] [--glibs] [--evelibs] [--bindir] [--libdir] [--incdir] [--etcdir] [--tutdir] [--srcdir] [--noauxcflags] [--noauxlibs] [--noldflags] [--has-<feature>] [--arch][--python-version] [--python2-version] [--python3-version] [--cc] [--cxx] [--f77] [--ld] [--help]

**hist_mass_vn.C:11:10:**  **fatal error:** TFile.h: No such file or directory

11 | #include **"TFile.h"**

| **^ ~~~~~~~~ **

compilation terminated.

```

This time I am getting errors for all the .h files included.

Regards,  
Nihar

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 21, 2023, 8:04am UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195/4 "2023-01-21T08:04:19Z")

</div>

`$(root-config --cxx --cflags) -o vn.out hist_mass_vn.C $(root-config --glibs) -lTMVA`

---

<div class="post-metadata">

**Author:** ![Nihar\_Saha](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nihar_saha/32/19673_2.png) [@Nihar\_Saha](https://root-forum.cern.ch/u/Nihar_Saha)\
**Post date:** [January 21, 2023, 9:19am UTC](https://root-forum.cern.ch/t/compilation-error-for-tmva-reader-and-instances/53195/5 "2023-01-21T09:19:16Z")

</div>

Thank you it works!

Regards,  
Nihar
