vendredi 18 octobre 2019

Is normal to put all the cpp/cc files when compiling with g++?

I'm doing the "Hello World" in the GTKMM tutorial, the "app" uses three files, the main.cc, the helloworld.h y 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 it has sence because the header is included in Main but not the Helloworld.cc, the thing is i'm kinda scary of including it because i readed 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, like not ignoring helloworld.cc anymore.

So, since using the last command works, ¿it 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 comand?, if not, if i must use #Include, ¿is good practice using #include for all cc used files?.

Sry if bad written, English is not my native lang.

Aucun commentaire:

Enregistrer un commentaire