Automatically include header files while compiling using g++

When running a macro using root -l, 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

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