# Automatically include header files while compiling using g++

**URL:** <https://root-forum.cern.ch/t/automatically-include-header-files-while-compiling-using-g/45322>\
**Category:** Newbie\
**Tags:** root\
**Created:** [June 9, 2021, 8:16pm UTC](https://root-forum.cern.ch/t/automatically-include-header-files-while-compiling-using-g/45322 "2021-06-09T20:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkalbhor](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pkalbhor/32/21674_2.png) [@pkalbhor](https://root-forum.cern.ch/u/pkalbhor)\
**Post date:** [June 9, 2021, 8:16pm UTC](https://root-forum.cern.ch/t/automatically-include-header-files-while-compiling-using-g/45322/1 "2021-06-09T20:16:38Z")

</div>

When running a macro using `root -l macro.cc`, I do not need to explicitly mention `#include header.h` lines for using ROOT classes. I have no idea how ROOT does that internally.

But if I want to compile this macro using `g++` compiler, I need to declare those lines explicitly.  
I have a code where I am using so many ROOT classes and I want to compile this code using g++.  
I would like to know how I can compile a code using `g++` compiler without using `#include` lines in the code.

* * *

_ROOT Version:_ 6.24  
_Platform:_ Ubuntu 20.04  
_Compiler:_ g++ 9.3.0

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [June 15, 2021, 7:33am UTC](https://root-forum.cern.ch/t/automatically-include-header-files-while-compiling-using-g/45322/2 "2021-06-15T07:33:10Z")

</div>

> [@pkalbhor](#):
>
> I would like to know how I can compile a code using `g++` compiler without using `#include` lines in the code.

If you **compile** a C/C++ program you must put the needed `#include` there is no other way.
