Compilation error for TMVA Reader() and Instances()

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:

/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,

Add: -lTMVA

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:

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.


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

1 Like

Thank you it works!