Builds Flashcards
What is program building?
The creation of an executable from one or more source files
What is a program executable?
A file that contains machine code instructions (instructions are OS and CPU dependant)
What are the two steps required for transforming C code into an executable?
Compilation and linking
What does preprocessing do?
It interprets all the preprocessing directives of one source file
What do preprocessing directives begin with?
#
What are the input and output of preprocessing?
Input: source code from one source file
Output: New source code with substitutions incorporated
What is a header file?
File containing information needed by multiple source files, such as data type definitions and function prototypes. It never contains function implementations or any statements.
Use ______ to include a header file from a library
angle brackets
Use ______ to include a header file from the current directory
double quotes
What does compiling do?
Translates source code into assembly code while performing optimizations
Compiler input:
Source code from one source file
Compiler output:
The corresponding assembly code
What does assembling do?
It translates assembly code into object code
Assembler input:
Assembly code from one source file
Assembler output:
Corresponding object code
What does linking do?
Combines code from multiple object files into one executable
Linking input:
Object code from multiple object files, including library ones
Linking output:
One executable file
Why do we separate compiling and linking?
Object files may come from different source languages, you can link object code from libraries into your executable, you only need to recompile the source files that have changed
What is a library?
A collection of related functions written by other programmers
To use a library:
Include the library header file, using a preprocessor directive, OR link in the library object file
What are the two types of linking?
Static linking and dynamic linking
What is static linking?
The library object code is copied into the executable- results in larger but faster executable
What is dynamic linking?
Default setting- object code is loaded at runtime. There’s a smaller executable, but slower execution time
What is a makefile?
Text file called Makefile with no file extension
What are Makefiles used for?
Managing the dependencies between files
Why use a makefile?
It keeps track of what needs to be recompiled
How do makefiles keep track of what needs to be recompiled?
Comparing timestamps
What’s a makefile macro?
Similar to a variable, they can be used to define groups of files and specify compilation options