Compiling Multiple C Files with G
You have inherited some poorly written C code consisting of a single CPP file containing the main function and various other functions, along with separate H files for class definitions. Instead of using the original command g main.cpp, you are wondering if you need to use a Makefile or if you can still use g main.cpp.
To compile multiple C files using g , you can either list all the additional CPP files after main.cpp in the command:
Alternatively, you can compile each file individually and then link the resulting .o files together. To do this, you would use the following commands:
The above is the detailed content of Can I Compile Multiple C Files with g Without a Makefile?. For more information, please follow other related articles on the PHP Chinese website!