Posted By: Anonymous
I’ve just inherited some C++ code that was written poorly with one cpp file which contained the main and a bunch of other functions. There are also
.h files that contain classes and their function definitions.
Until now the program was compiled using the command
g++ main.cpp. Now that I’ve separated the classes to
.cpp files do I need to use a makefile or can I still use the
g++ main.cpp command?
list all the other cpp files after main.cpp.
g++ main.cpp other.cpp etc.cpp
and so on.
Or you can compile them all individually. You then link all the resulting “.o” files together.