1

I am confused about .obj files created using C language. Does they contain machine code and is the machine code in binary language, as it is known that the machine can understand only binary language. Moreover, my thinking of machine code is that it is a set of machine instructions in binary language (I may be wrong). Please explain.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Navdeep
  • 823
  • 1
  • 16
  • 35
  • Define `.obj` file please. – πάντα ῥεῖ Aug 09 '15 at 12:21
  • 1
    what does this have to do with C or C++, exactly? – RamblingMad Aug 09 '15 at 12:21
  • @CoffeeandCode I think he is referring to the .obj files created by the Borland Turbo C++ compiler – Swastik Padhi Aug 09 '15 at 12:28
  • .obj file is a file that is being created in C when I compile my program with turbo c compiler. So I think this is very much related with C/C++. Why you guys are bent upon downgrading me. Is it wrong to ask questions here? I know you are highly rated people but does that means that beginners can't be part of this community. Rather than motivating you are discouraging man!! – Navdeep Aug 09 '15 at 12:30
  • 3
    @Navdeep you should specify the compiler i.e., **Borland Turbo C/C++** that produces these **.obj** files in your question. **C language** does not produce **.obj** files! – Swastik Padhi Aug 09 '15 at 12:35
  • 1
    @Navdeep your question is missing *lots* of details and is answerable by doing a few google searches. It's not personal, it just isn't a good question. – RamblingMad Aug 09 '15 at 12:38
  • 1
    @CrakC I am using Borland Turbo C++ 3.1. – Navdeep Aug 09 '15 at 12:57
  • @CoffeeandCode actually by doing a lot of google searches I got myself confused, that's why I asked question here. If it's possible for you please explain it here or send me some link that contains some clear explanation about it. The links I found contains lots and lots of information which actually didn't serve any purpose...Thanks – Navdeep Aug 09 '15 at 12:59
  • @Navdeep Pls go through the link that I have posted in my answer – Swastik Padhi Aug 09 '15 at 13:04
  • It is certainly easiest to assume it does. Not terribly relevant anymore these days, they often contain the intermediate language used between the front-end and the code generator. To support profile-guided or whole-program optimization, the linker generates the code. YMMV. – Hans Passant Aug 09 '15 at 13:21

1 Answers1

3

An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. .obj is the compiled object file that is used by the linker (along with the necessary library (.h) files) to create an executable. The executable is then loaded into the memory for execution using a loader.

Please read the following for more information- What is compiler, linker, loader?

enter image description here

Community
  • 1
  • 1
Swastik Padhi
  • 1,849
  • 15
  • 27