Static build
Encyclopedia
A static build is a compiled
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 version of a program which has been statically linked against libraries.

In computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, linking means taking one or more objects
Object code
Object code, or sometimes object module, is what a computer compiler produces. In a general sense object code is a sequence of statements in a computer language, usually a machine code language....

 generated by compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

s and assemble them into a single executable
Executable
In computing, an executable file causes a computer "to perform indicated tasks according to encoded instructions," as opposed to a data file that must be parsed by a program to be meaningful. These instructions are traditionally machine code instructions for a physical CPU...

 program. The objects are program modules containing machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...

 and symbol definitions, which come in two varieties:
  • Defined or exported symbols are functions or variable
    Variable (programming)
    In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

    s that are present in the module represented by the object, and which should be available for use by other modules.
  • Undefined or imported symbols are functions or variables that are called or referenced by this object, but not internally defined.


A linker program then resolves references to undefined symbols by finding out which other object defines a symbol in question, and replacing placeholders with the symbol's address. Linkers can take objects from a collection called a library
Library (computer science)
In computer science, a library is a collection of resources used to develop software. These may include pre-written code and subroutines, classes, values or type specifications....

. The final program does not include the whole library, only those objects from it that are needed. Libraries for diverse purposes exist, and one or more system libraries are usually linked in by default.

Modern operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 environments allow dynamic linking, or the postponing of the resolving of some undefined symbols until a program is run. That means that the executable still contains undefined symbols, plus a list of objects or libraries that will provide definitions for these. Loading the program will load these objects/libraries as well, and perform a final linking.

In a statically built program, no dynamic linking occurs: all the bindings have been done at compile time
Compile time
In computer science, compile time refers to either the operations performed by a compiler , programming language requirements that must be met by source code for it to be successfully compiled , or properties of the program that can be reasoned about at compile time.The operations performed at...

.

Dynamic linking offers two advantages:
  • Often-used libraries (for example the standard system libraries) need to be stored in only one location, not duplicated in every single binary.
  • If a library is upgraded or replaced, all programs using it dynamically will immediately benefit from the corrections. Static builds would have to be re-linked first.


On the other hand, static builds have a very predictable behavior (because they do not rely on the particular version of libraries available on the final system), and are commonly found in forensic and security tools to avoid possible contamination or malfunction due to broken libraries on the examined machine. The same flexibility that permits an upgraded library to benefit all dynamically-linked applications can also prevent applications that assume the presence of a specific version of a particular library from running correctly. If every application on a system must have its own copy of a dynamic library to ensure correct operation, the benefits of dynamic linking are moot.

Another benefit of static builds is their portability: once the final executable file has been compiled, it is no longer necessary to keep the library files that the program references, since all the relevant parts are copied into the executable file. As a result, when installing a statically-built program on a computer, the user doesn't have to download and install additional libraries: the program is ready to run.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK