0

Why are the files of C++ after compiling called object file? For example if I type in in the linux shell

g++ -c <name>.cpp

I understood how they are working but the name confuse me a little bit.

If I'm not mistaken *.o files are similar to *.class files in Java, right?

bilaljo
  • 358
  • 1
  • 6
  • 13
  • 2
    Does this answer your question? [What is \*.o file?](https://stackoverflow.com/questions/2186246/what-is-o-file) – Yksisarvinen Mar 27 '20 at 09:39
  • Thank's for the link. My question isn't what is an *o file. I'm only confused about the name "object file" (because it would make more sense in my mind if they called "machine file" or something like that). – bilaljo Mar 27 '20 at 09:43
  • 1
    There are similarities to `.o` files, but they are not very alike. `.class` file is complete thing that could potentially be run (if there's `Main()` etc.) and is written in Java byte code. `.o` file is in assembly and it is just a single `cpp` compiled as much as possible. It doesn't have definitions of functions defined in other `.cpp` files, linker has to provide them. – Yksisarvinen Mar 27 '20 at 09:47
  • 1
    The term goes back to at least IBM's System 360 (1973), which defined "source module", "object module", and "load module"; the term may have been in use before that. (It's not uncommon for things to have weird names. Have you noticed that a "compiler" doesn't create compilations? It used to, though - in 1955, a "compiler" was what we call a "linker" today.) – molbdnilo Mar 27 '20 at 10:26
  • Thank's for the answers that makes sense. – bilaljo Mar 27 '20 at 21:30

0 Answers0