|Securing and Optimizing Linux: RedHat Edition -A Hands on Guide|
|Prev||Chapter 13. Linux -The Compiler functionality||Next|
All the programs in Red Hat distributions of Linux are provided as RPM files. An RPM file, also known, as a package, is a way of distributing software so that it can be easily installed, upgraded, queried, and deleted. However, in Unix world, the defacto-standard for package distribution continues to be by way of so-called tarballs. Tarballs are simply compressed files that can be readable and uncompressed with the tar utility. Installing from tar is usually significantly more tedious than using RPM. So why would we choose to do so?
Unfortunately, it takes a few weeks for developers and coders to get the latest version of a package converted to RPMs because many developers first release them as tarballs.
When developers and vendors release a new RPM, they include a lot of options that often are not necessary. Those organization and companies don't know what options you will need and what you will not, so they include the most used to fit the needs of everyone.
Often RPMs are not optimized for your specific processors; companies like Red Hat Linux build RPMs based on a standard PC. This permit their RPM packages to be installed on all sorts of computers since compiling programs for an i386 machine can fit on all systems.
Sometimes you download and install RPM, which other people around the world are building and make available for your purposes. This can pose conflicts in certain cases depending how this individual built the package, such as errors, security and all the other problems described above.
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 compiles his source using the compiler and gets a result of some sort. It's not at all 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:
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 ld program behind the scenes.
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.
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.
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.
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.
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.