Linux Compile Multiple C++ Files
Compile Two Files:
$ CC -c Main.cc Sales_item.cc # by default generates a.exe # some compilers generate a.out # puts the executable in main.exe $ CC -c main.cc Sales_item.cc -o main
More efficient way is to only compile the modified file. Thus we need to compile original files into object files.
Link Object Files:
$ CC -c main.cc # generates main.o $ CC -c Sales_item.cc # generates Sales_item.o $ CC main.o Sales_item.o -o main # by default generates a.exe; # some compilers generate a.out