# Impossible to root -l my .C codes

**URL:** <https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841>\
**Category:** Newbie\
**Created:** [May 13, 2023, 12:47pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841 "2023-05-13T12:47:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/alo/32/33312_2.png) [@Alo](https://root-forum.cern.ch/u/Alo)\
**Post date:** [May 13, 2023, 12:47pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/1 "2023-05-13T12:47:50Z")

</div>

Hi everyone,

I have a problem with all my .C codes with int main() when I try to execute them with the root -l command. Indeed, when I do this, I obtain :

```auto
alo@MacBook-Pro TMVA_TEST_Run1 % root -l MergeNTuplesForTraining.C
root [0] 
Processing MergeNTuplesForTraining.C...
input_line_9:2:2: error: no matching function for call to 'MergeNTuplesForTraining'
 MergeNTuplesForTraining() /* .x tries to invoke function `MergeNTuplesForTraining` */
 ^ ~~~~~~~~~~~~~~~~~~~~~~
/Users/alo/Documents/STAGE_M2.nosync/Root_stage_M2/TMVA_TEST_Run1/MergeNTuplesForTraining.C:16:5: note: candidate function not viable: requires at least 2 arguments, but 0 were provided
int MergeNTuplesForTraining(std::string OutputFileName, std::vector<std::pair<std::string, std::string>> InputFilenames, uint MaxEv = -1)
    ^

```

My code is like :

```auto
int MergeNTuplesForTraining(std::string OutputFileName, std::vector<std::pair<std::string, std::string>> InputFilenames, uint MaxEv = -1) {
// My function
}

int main() {
  std::vector<std::pair<std::string, std::string>> SignalForTraining_Up_Vec;
  SignalForTraining_Up_Vec.emplace_back(std::make_pair("/Users/alo/Documents/STAGE_M2.nosync/Root_stage_M2/TMVA_TEST_Run1/Tuples/Signal/DTT_13512010_Bs_Kmunu_DecProdCut_Up_Py8_MC12.root","Bs2KmuNuTuple"));

  MergeNTuplesForTraining("DataForTraining/SignalForTraining_Up.root", {SignalForTraining_Up_Vec});
}

```

And I obtain this with all my codes.

But, if I do the following thing :

```auto
alo@MacBook-Pro TMVA_TEST_Run1 % root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.28/04 https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosxarm64 on May 08 2023, 02:44:07 |
  | From tags/v6-28-04@v6-28-04 |
  | With Apple clang version 14.0.3 (clang-1403.0.22.14.1) |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] .L MergeNTuplesForTraining.C 
root [1] main()

```

Everything is working ! Can you help me with that ? Thanks !

* * *

_ROOT Version:_ 6.28/04  
_Platform:_ macOS 13.3.1 (a) (22E772610a)  
_Compiler:_ clang-1403.0.22.14.1

* * *

---

<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:** [May 14, 2023, 9:18am UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/2 "2023-05-14T09:18:48Z")

</div>

`root -l -e '.L MergeNTuplesForTraining.C' -e 'main();'`

---

<div class="post-metadata">

**Author:** ![Alo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/alo/32/33312_2.png) [@Alo](https://root-forum.cern.ch/u/Alo)\
**Post date:** [May 14, 2023, 12:22pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/3 "2023-05-14T12:22:36Z")

</div>

Thanks for the answer, it is working ! But, is it possible to run my .C just by doing `root -l .C` ? And, if yes, which modification I need to make on my code ?

---

<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:** [May 14, 2023, 2:42pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/4 "2023-05-14T14:42:24Z")

</div>

[ROOT Primer → ROOT Macros](https://root.cern/primer/#root-macros) ;  
[ROOT Manual → Basics → ROOT macros and shared libraries](https://root.cern/manual/root_macros_and_shared_libraries/)

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [May 15, 2023, 2:26pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/5 "2023-05-15T14:26:58Z")

</div>

> [@Alo](#):
>
> And, if yes, which modification I need to make on my code ?

Yes, you just need to rename the function `main` to `MergeNTuplesForTraining` (i.e. name of the script without extension)

---

<div class="post-metadata">

**Author:** ![Alo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/alo/32/33312_2.png) [@Alo](https://root-forum.cern.ch/u/Alo)\
**Post date:** [May 15, 2023, 3:01pm UTC](https://root-forum.cern.ch/t/impossible-to-root-l-my-c-codes/54841/6 "2023-05-15T15:01:58Z")

</div>

Yeah, I figured that’s out afterwards but thanks!
