is all the .obj or .o file compatible?

F

Flash Gordon

Danny said:
Can anyone tell me if all the .obj or .o files are compatible?

This is not a C question, and therefore not on topic here.

<OT>
No, they are not all compatible. A .o file for Linux is very unlikely to
work on Windows.
</OT>

If you want anything more specific about object files, please ask on a
group dedicated to your system, NOT here.
 
J

Jaspreet

Danny said:
Can anyone tell me if all the .obj or .o files are compatible?

No way, they are platform dependant plus have a whole lot of other
dependencies. If they were compatiable you would be looking at a
picture similar to compiling on one platform and executing it on
another which is not true.
 
W

Walter Roberson

No way, they are platform dependant plus have a whole lot of other
dependencies. If they were compatiable you would be looking at a
picture similar to compiling on one platform and executing it on
another which is not true.

What you write is more or less right, but I think it gives a bit
of the wrong impression.

Different operating systems do generally use different object file
formats, sometimes supporting multiple object file formats on one
OS. But the object file format is a different question, really,
then what instruction set a particular platform supports.

Some object file formats support multiple executable portions (for
different instruction sets, or for 32 bit vs 64) within the same object
file; an example of this is Apple's announcement that object files
would share PowerPC and Intel executables.

Unix-like systems tend to adopt one of a small number of object file
formats, so that they do not need to "reinvent the wheel". Some of the
format names are "COFF" (older, use is declining); "ELF" (not as old,
but not fresh); "dwarf" (newer). gcc supports ELF and dwarf formats; I
do not know at the moment if COFF format is being maintained in gcc.

A consequence of this is that object files have a tendency to be
cross-platform compatible (in the sense that the same tool would be
able to extract debugging and link data) -- even when the
instruction set of the binaries is incompatible. The situation
is sort of like the way that most countries agree on standardized
letter and parcel sizes, so a letter can go from one country to
another, even though the -contents- of the letter might be
unintelligable to most people in the destination country.
 
C

Chris Torek

Unix-like systems tend to adopt one of a small number of object file
formats, so that they do not need to "reinvent the wheel". Some of the
format names are "COFF" (older, use is declining); "ELF" (not as old,
but not fresh); "dwarf" (newer). ...

Off-topic technical note: "dwarf" is not an object file format,
while "ELF" is. (Dwarf and dwarf-2 are debugging data sub-formats
normally appearing within ELF files. The GNU binutils can use
either "stabs" or dwarf within ELF files.)
 
T

Tim Prince

Flash said:
This is not a C question, and therefore not on topic here.
I'd be surprised if many people could use C without dealing with one or
the other.
Perhaps the OP meant "all obj and .o files intended for use with C
compilations."
Aside from the various format possibilities, and possibility of
incompatible instruction sets, these files are likely to contain
references to the run-time libraries of a specific compiler and/or a
specific OS version. At the very least, they depend on specific header
files, at a lower level than the compatibility implied in C standard.
 
E

emanshu, Munish Nayyar

Hi danny,

No, .obj and .o files are not comaptible.
though both are relocatable file but are in different format.
the scope of both is same(i.e. compiled source,relocatables) but are
platform dependent.
usually, .o is format of relocatable files or compiled files in
Unix/Linux variant while .obj is compiled ouput for windows based.

so, i hope this clears your doubt.

rgrds,
Munish Nayyar
emanshu "Innovative MInd"
 
T

Tim Prince

Hi danny,

No, .obj and .o files are not comaptible.
though both are relocatable file but are in different format.
the scope of both is same(i.e. compiled source,relocatables) but are
platform dependent.
usually, .o is format of relocatable files or compiled files in
Unix/Linux variant while .obj is compiled ouput for windows based.

so, i hope this clears your doubt.
This only confuses the issue. .o and .obj files on Windows are usually
interchangeable, aside from the fact that they are usually built against
different headers and libraries, but your explanation seems to
contradict that. .o and .obj files can be renamed either way, without
making a difference to tools which accept both. As others will no
doubt point out again, the C standard says nothing about which name you
give them.
 
M

Mark McIntyre

I'd be surprised if many people could use C without dealing with one or
the other.

So would I but that doesn't make it ontopic. Consider that you'd be
equally surprised if many people could use C without the letter i, or
a computer of some sort, or electricity, or access to oxygen.
 
M

Michael Wojcik

I'd be surprised if many people could use C without dealing with one or
the other.

I don't believe there's any limit to the number of people who could
use EPM C on the AS/400, which does not use anything called a ".obj
file" or a ".o file", or even anything roughly equivalent to those
things on the platforms where they do appear. (Some C implementations
for the '400 do have something that is in some ways similar to an
"object file", but it doesn't have a name that contains ".obj" or
".o".)

However, the point is moot; it's still OT for comp.lang.c. Few people
"use C" (in the sense of writing C programs) without a keyboard; that
doesn't make questions about keyboards on-topic here.

--
Michael Wojcik (e-mail address removed)

Unfortunately, as a software professional, tradition requires me to spend New
Years Eve drinking alone, playing video games and sobbing uncontrollably.
-- Peter Johnson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top