I am new to Linux environment, and I just started using gcc. We have small project that has 7 to 8 cpp files. When I try to compile my files, I wonder why there is .o file for every .cpp file. There is only one main.
Asked
Active
Viewed 390 times
2 Answers
7
This is the way compilation works. Each translation unit gets turned into object code ( the .o files) then the object files get linked together and with other libraries into the final executable file. Normally the build system hides object files somewhere, but you're probably using a very simple build system or script which doesn't bother.

bames53
- 86,085
- 15
- 179
- 244
5
.o is an object file created during compilation of each cpp.
for more info Why Compile to an Object File First?