# Compile root script with g++ to execute it in background as "-b" option for macros

**URL:** <https://root-forum.cern.ch/t/compile-root-script-with-g-to-execute-it-in-background-as-b-option-for-macros/49157>\
**Category:** Newbie\
**Created:** [March 13, 2022, 5:16pm UTC](https://root-forum.cern.ch/t/compile-root-script-with-g-to-execute-it-in-background-as-b-option-for-macros/49157 "2022-03-13T17:16:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simone\_Vallarino](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/simone_vallarino/32/29085_2.png) [@Simone\_Vallarino](https://root-forum.cern.ch/u/Simone_Vallarino)\
**Post date:** [March 13, 2022, 5:16pm UTC](https://root-forum.cern.ch/t/compile-root-script-with-g-to-execute-it-in-background-as-b-option-for-macros/49157/1 "2022-03-13T17:16:31Z")

</div>

Hi everyone,

i’m trying to compile my root script using g++, but I want to run it without it shows the canvases, same way as the “-b” option for running macro.

Do you have any suggestion?

I’m currently using the following command:  
g++ -I `root-config --incdir --cflags` -Wall -O2 analysis.C myFunc/myFit.C myFunc/readPar.C -o exe\_Analysis `root-config --libs`

---

<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:** [March 13, 2022, 5:24pm UTC](https://root-forum.cern.ch/t/compile-root-script-with-g-to-execute-it-in-background-as-b-option-for-macros/49157/2 "2022-03-13T17:24:19Z")

</div>

In your “main”, add: `gROOT->SetBatch(kTRUE);`
