# Run tmva on a standalone application using g++

**URL:** <https://root-forum.cern.ch/t/run-tmva-on-a-standalone-application-using-g/14961>\
**Category:** TMVA\
**Created:** [September 21, 2012, 11:51am UTC](https://root-forum.cern.ch/t/run-tmva-on-a-standalone-application-using-g/14961 "2012-09-21T11:51:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![magistros](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@magistros](https://root-forum.cern.ch/u/magistros)\
**Post date:** [September 21, 2012, 11:51am UTC](https://root-forum.cern.ch/t/run-tmva-on-a-standalone-application-using-g/14961/1 "2012-09-21T11:51:39Z")

</div>

Hi all,  
I have a code, where I am using the TMVA factory in order to train a Neural Network. I want to execute it, outside of CINT, so, I import all the headers but when I am trying:

```auto

```

I get these messages

` In function `main':
trainTMVA.cpp:27: undefined reference to `TMVA::Factory::Factory(TString, TFile*, TString)'
trainTMVA.cpp:29: undefined reference to `TMVA::Factory::AddSignalTree(TTree*, double, TMVA::Types::ETreeType)'
trainTMVA.cpp:30: undefined reference to `TMVA::Factory::AddBackgroundTree(TTree*, double, TMVA::Types::ETreeType)'
trainTMVA.cpp:32: undefined reference to `TMVA::Factory::SetWeightExpression(TString const&, TString const&)'
trainTMVA.cpp:34: undefined reference to `TMVA::Factory::AddVariable(TString const&, char, double, double)'
trainTMVA.cpp:35: undefined reference to `TMVA::Factory::AddVariable(TString const&, char, double, double)'
trainTMVA.cpp:36: undefined reference to `TMVA::Factory::AddVariable(TString const&, char, double, double)'
trainTMVA.cpp:37: undefined reference to `TMVA::Factory::AddVariable(TString const&, char, double, double)'
trainTMVA.cpp:38: undefined reference to `TMVA::Factory::AddVariable(TString const&, char, double, double)'
/tmp/ccTzjrLe.o:trainTMVA.cpp:39: more undefined references to `TMVA::Factory::AddVariable(TString const&, char, double, double)' follow
/tmp/ccTzjrLe.o: In function `main':
trainTMVA.cpp:52: undefined reference to `TMVA::Factory::PrepareTrainingAndTestTree(TCut const&, TString const&)'
trainTMVA.cpp:57: undefined reference to `TMVA::Factory::BookMethod(TMVA::Types::EMVA, TString, TString)'
trainTMVA.cpp:58: undefined reference to `TMVA::Factory::BookMethod(TMVA::Types::EMVA, TString, TString)'
trainTMVA.cpp:59: undefined reference to `TMVA::Factory::BookMethod(TMVA::Types::EMVA, TString, TString)'
trainTMVA.cpp:61: undefined reference to `TMVA::Factory::TrainAllMethods()'
trainTMVA.cpp:63: undefined reference to `TMVA::Factory::TestAllMethods()'
trainTMVA.cpp:65: undefined reference to `TMVA::Factory::EvaluateAllMethods()'
collect2: error: ld returned 1 exit status`

the $TMVASYS variable is already set.  
What is going wrong?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [September 21, 2012, 12:11pm UTC](https://root-forum.cern.ch/t/run-tmva-on-a-standalone-application-using-g/14961/2 "2012-09-21T12:11:11Z")

</div>

Try to add “-lTMVA”.

---

<div class="post-metadata">

**Author:** ![magistros](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@magistros](https://root-forum.cern.ch/u/magistros)\
**Post date:** [September 21, 2012, 12:17pm UTC](https://root-forum.cern.ch/t/run-tmva-on-a-standalone-application-using-g/14961/3 "2012-09-21T12:17:32Z")

</div>

It works like a charm!!!  
Thank you so much Pepe!!
