mardi 20 mars 2018

Compilation of cpp code

I am studying OOP with c++ and using g++ compiler. I was wondering, when implementing separate compilation, what is the point of compiling to object files and then linking everything into an executable, instead of just using g++ to compile and link everything directly? What are the pros/cons of each process?

    for example:  g++ -c main.cpp func1.cpp func2.cpp -o main.o func1.o func2.o 

                  g++ -o test.exe main.o func1.o func2.o 

OR simply

                  g++ main.cpp func1.cpp func2.cpp -o test.exe

they do the same thing it seems, so what is the point of both processes? (I apologize if there are any mistakes that make the question less clear, thank you for your time)

Aucun commentaire:

Enregistrer un commentaire