I'm doing the "Hello World" in the GTKMM tutorial, the "app" uses three files, the main.cc
, helloworld.h
and helloworld.cc
.
At the beginning I thought that compiling the main.cc :
g++ -o HW main.cc $(pkg-config ... )
would be enough, but gives an error (undefined reference to Helloworld::Helloworld
), etc.
In other words, it compiles the main and the header, but not the HW
class, and this makes sense because the header is included in Main but not the Helloworld.cc
. The thing is I'm kinda scared of including it because I read in other question that "including everything was a bad practice".
That being said, when I compile using all the files in the same command:
g++ -o HW main.cc helloworld.cc $(pkg-config ... )
the "app" works without errors.
So, since using the last command works, is compiling in this way a good practice?
What happens if my app uses a big ton of classes?
Must I manually write them all down in the command?
If not, must I use #include
?
Is it good practice using #include for all cc used files?