When a program is compiled from say C or C++ source code, a compiler such as
gcc (see below) translates that code into the native binary language of the CPU, so that the program can be executed. Thus human readable material (source code) is turned into a non-human readable format (machine readable binary code).
Binaries and the Filesystem
If you enter
echo $PATH, you will see a locations of all the executables on the system, both compiled binaries and scripts:
In the filesystem hierarchy key system tools such as
getty are present in
/sbin respectively, and other tools such as
chroot are present in
/usr/sbin respectively. If you compile a program by downloading the source code, configuring the build, and the installing it, your program by default should go in
/usr/local/bin and its other files in the
Probably one of the most well known tools used to compile binaries is
gcc, which is known as the GNU Compiler Collection and earlier as the GNU C compiler; the version shipped with Ubuntu 12.04 is
gcc 4.6.3. As it notes in the offical GNU manual,
GCC is an integrated distribution of compilers for several major programming
languages. These languages currently include C, C++, Objective-C, Objective-C++,
Java, Fortran, Ada, and Go.
Compiling a binary
The three commands
sudo make install (or
sudo checkinstall) are often used together in order to compile a program.
./configure, amongst other things, checks the version of
gcc installed and prepares the build environment. The
makefile is one of the most important things generated from running
./configure as it directs the build when
make is run. The GNU make manual details the process in great depth. In sum, the rules in the
makefile determine the main goal (to create an executable) so that the source code
.c files will be made into compiled files (
.o files) in order to generate the target executable file.
Two great resources are these Ubuntu compilation guides here and here, which contain some great advice and information for those new to compiling. Other resources such as the GNU
gcc manual and the
make manual I have mentioned already. For more information on C and creating a simple little C program, see chapter 22 of Rute and chapter 24 of the Linux Command Line.