An object file is a computer file generated by a program called a compiler and contains data as well as instructions. Compilers translate programming language source code into an intermediate machine-readable form known as object code. Smaller programs might be compiled in a single object file, while larger programs are typically compiled into several files of related function. These individual object files are joined by a linker and operating system specific information is added to form an executable program.
In common practice, an object file is denoted by an ".obj" file extension. There are several different formats for these files, however. The most common are the Intel® Relocatable Object Module Format (OMF), and the Common Object File Format (COFF) of Windows® and UNIX® System V. In many INIX® systems, the Executable and Linkable Format (ELF) has come to replace COFF.
Regardless of format, an object file typically contains three types information that allows it to interact with other program modules. Procedures and data that are open to outside reference are assigned names by which they can be called from other modules. Similarly, references to information outside the module are noted but not assigned a name. When the files are linked, the unnamed references will be assigned the name given them in the module where they were originally defined. Local names are used for instructions and data referred to solely within a module.
Not all linkable code is stored as object files. Libraries are collections of precompiled routines that are stored as object code. They are produced in much the same way as object files and are useful for storing frequently called procedures. When a linker does not find a reference within other object files, it will automatically search for it in a library file. Most implementations of a programming language come with a standard library of functions.
By means of dynamic linking, an object file can be simultaneously used by multiple executing programs. Instead of binding object code to a program when linked, it is it is retrieved when the program is loaded or at runtime when a procedure is referenced. In the Windows® environment, these are known as dynamic link libraries and are denoted by a ".dll" extension. Systems similar to Unix® often term this type of file a dynamic shared object (DSO). This type of object file may also be implemented for use with a particular program and would be a part of that program's installation.