Compiling software on your system
A program is something a computer can execute. Originally, somebody wrote the “source code” in a programming language he/she could understand (e.g., C, C++). The program “source code” also makes sense to a compiler that converts the instructions into a binary file suited to whatever processor is wanted (e.g. a 386 or similar). A modern file format for these “executable” programs is Elf. The programmer shows his source to the compiler and gets a result of some sort. It’s not atall uncommon that early attempts fail to compile, or having compiled, fail to act as expected. Half of programming is tracking down and fixing these problems (debugging).
For the beginners there are more aspect and new words relating to compilation of a source code that you must know, these includes but are not limited to:
The Multiple Files
One-file programs are quite rare. Usually there are a number of files (say *.c, *.cpp, etc) that are each compiled into object files (*.o) and then linked into an executable. The compiler is usually used to perform the linking and calls the ‘Id’ program behind the scenes.
The Makefiles
The Makefiles are intended to aid you in building your program the same way each time. They also often help with speed. The “make” program uses “dependencies” in the Makefile to decide what parts of the program need to be recompiled. If you change one source file out of fifty you hope to get away with one compile and one link step, instead of starting from scratch.
The Libraries
Programs can be linked not only to object files (*.o) but also to libraries that are collections of object files. There are two forms of linking to libraries: static, where the code goes in the executable file, and dynamic, where the code is collected when the program starts to run.
The Patches
It was common before for executable files to be given corrections without recompiling them. Now this practice has died out; in modern days, people changes a small proportion of the whole source code, putting a change into a file called a “patch”. Where different versions of a program are required, small changes to code can be released this way, saving the trouble of having two large distributions.
The Errors in Compilation and Linking
Errors in compilation and linking are often typos, omissions, and misuse of the language. Check that the right includes files are used for the functions you are calling. Unreferenced symbols are the sign of an incomplete link step. Also checks if the necessary development libraries (GLIBC) or tools (GCC, DEV86, AUTOMAKE, etc) are installed on your system.
The Debugging
Debugging is a large topic. It usually helps to have statements in the code that inform you of what is happening. To avoid drowning in output you might sometimes get them to print out only the first 3 passes in a loop. Checking that variables have passed correctly between modules often helps. Get familiar with your debugging tools.