Questions tagged [object-files]

An object file is the real output from the compilation phase.

An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)

A linker takes all these object files and combines them to form one executable (assuming that it can, ie: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (-c is a common "just compile; don't link" option.)

293 questions
13
votes
4 answers

Can't link assembly file in Mac OS X using ld

I'm trying to run a basic assembly file using 64 Bit Mac OS X Lion, using nasm and ld which are installed by default with Xcode. I've written an assembly file, which prints a character, and I got it to build using nasm. nasm -f elf -o program.o…
Jack Greenhill
  • 10,240
  • 12
  • 38
  • 70
13
votes
2 answers

Convert .o file to .exe

Is it possible to convert an object file .o that was created from a .c source code to .exe? And if it is possible is there a direct command using gcc?
Dman
  • 139
  • 1
  • 1
  • 5
13
votes
3 answers

How to make an executable file from a c object file?

How to make an object file to executable file?
MalarN
  • 315
  • 3
  • 7
  • 20
12
votes
1 answer

What is the difference between a .o object file and a .so library file?

Like the title says, what is the difference between a "program object file" (.o extension) and a "library file" (.so extension)
ozona
  • 446
  • 4
  • 12
11
votes
4 answers

Can I link object files made by one compile to those made by another one?

To be more specific, lets assume that both compilers are on the same platform (OS + instruction set). However, one of the object files was made from a compiler-dependent code. On the other hand - the code is object oriented and respects…
Rusty Horse
  • 2,388
  • 7
  • 26
  • 38
11
votes
1 answer

What is an LLVM virtual section in the context of object files?

Whilst looking at a bugfix in the LLVM source code, I came across the term, "virtual section" and wondered what it meant. I tried Googling a few different terms and browsing the source code further, but all I managed to find was that the…
OMGtechy
  • 7,935
  • 8
  • 48
  • 83
11
votes
1 answer

symbol table and relocation table in object file

From what I understand, instructions and data in an object file all have addresses. First data item start at address 0 and first instruction also start at address 0. The relocation table contains information about instructions that need to be…
Carlj901
  • 1,329
  • 4
  • 24
  • 39
10
votes
2 answers

How to list all externally-undefined symbols of a static library on Linux?

I have a static library libfoo.a, which is just a compression of multiple .o files. I am looking for a way to list all symbols that appear in the static library as UND have no definition in this static library So that I can find out all external…
lz96
  • 2,816
  • 2
  • 28
  • 46
10
votes
1 answer

Pre-compiled Windows OMF BLAS/LAPACK?

Is there anywhere I can get pre-compiled BLAS and LAPACK binaries for Windows in OMF object format? I want to link some D language code to these. I'm aware of where I can get the relevant libs in COFF format. I'm also aware of the objconv tool,…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
10
votes
4 answers

Too many sections, assembler error, using boost::spirit

I'm in the progress of writing a compiler for a subset of Java, using boost::spirit, for lexing and parsing. During compilation of the lexer/parser phase, the compiler consumes 1.6GB of RAM (g++ (GCC) 4.8.1), this is not an issue however, as there's…
Skeen
  • 4,614
  • 5
  • 41
  • 67
10
votes
2 answers

C/C++: What is the difference between a statically-linked library and an object file?

I understand that code included in an executable at compile-time can come from object files (.o files) and statically-linked libraries (.lib/.a files). What is fundamentally and conceptually the difference between these two? Why is there a…
user553702
  • 2,819
  • 5
  • 23
  • 27
9
votes
7 answers

Object files in an executable in Linux

Is there a way to find the object files from which the current executable is generated in Linux (RHEL to be specific). I understand that one can use "nm" to find the exported symbols, "ldd" to find dependent shared object. But I could not find…
spkhaira
  • 821
  • 7
  • 18
9
votes
3 answers

On what does the size of an C++ object file depend?

Whenever we compile a c++ file, an obj file is generated. I want to know that on what factors does the size of the obj file depend? Just to make my question more clear, For example a c++ file contains a class declaration and this class has 1 integer…
V K
  • 471
  • 8
  • 13
9
votes
4 answers

C/C++. Advantages of libraries over combined object files

While it is commonplace to combine multiple object files in a library, it is possible (at least in Linux) to combine multiple object files into another object file. (See combine two GCC compiled .o object files into a third .o file) As there are…
Simon
  • 623
  • 1
  • 8
  • 13
9
votes
1 answer

Why is an object file needed to generate an executable file?

When we compile code, an object file is generated. From that object file, an executable file is generated in the linking process. Why do we need an object file? What is the use of an object file? Can't it be possible that an executable file is…
shreyas_patel21
  • 317
  • 1
  • 4
  • 14
1
2
3
19 20