Originally Published: Wednesday, 8 September 1999 Author: Rob Thomas
Published to: news_learn_firststep/Firststep News Page: 1/1 - [Printable]

Compile It Yourself

Building software is an integral part of the Linux Operating System. It is not absolutely necessary, but compiling software yourself ensures that you get complete customizability, and is the foundation if the open source movement.

   Page 1 of 1  

Rob Thomas
Building software is an integral part of the Linux Operating System. It is not absolutely necessary, but compiling software yourself ensures that you get complete customizability, and is the foundation if the open source movement.

Most, if not all, Linux systems will come with a complete set of GNU compiler utilities. These include (but are not limited to) gcc, g++, make, and autoconf. The utilities 'autoconf' and 'make' both simplify compiling software tremendously.

When building your own software, it is imperative that you read whatever documentation comes with the software. As per GNU standards, there will usually be several files included with the package.

These include (but are not limited to) README, INSTALL, CREDITS, and COPYING. The COPYING file (also sometimes referred to as the LICENSE file) will almost always have some sort of licensing information, such as the GNU General Public License, telling you what you can and cannot do with the software.

The CREDITS file describes the author(s), and any help the author may have received. The INSTALL file is the most important key to building a package. It will generally contain all the information you'll need when installing a new piece of software.

It may be as simple as a few lines describing the commands you need to type to build the software, or may be several pages long, going through the intricate details surrounding different options and operating systems. Whatever the INSTALL file says, it is usually a good idea to read it before you do anything else.

The README file is also important. It may come in place of the INSTALL file, or may be by itself. Not all software authors follow the same standards. Sometimes there is good in formation on installing the software located within this file. Therefore it is generally a good idea to also read this file before you install.

As the case is with INSTALL, README can be either a few lines describing the nature of the program, or several pages (or even chapters) long, discussing how to use the program. Whatever it's nature, it is a good idea to read it.

Here is a sample build of some software. I have downloaded a beta version of a network tool, Nmap. After carefully reading the simple INSTALL file, I am ready to build it. For all intents and purposes, my prompt will be a dollar sign ( $ ).

$ ./configure

This is the first step in building an application. The autoconf utilities will determine if you have all the software you need to build this program successfully. This will display a long list of output, such as:

loading cache ./config.cache checking for gcc... (cached) gcc checking whether the C compiler (gcc ) works... yes checking whether we are using GNU C... (cached) yes

If the script finishes and does not report any problems, this is usually a sign that you are all ready to build the program. We will now simply run the 'make' command.

$ make This will now display an enormous amount of confusing data, which looks something like this:

Compiling libpcap make[1]: Entering directory `/tmp/nmap-2.3BETA5/libpcap-possiblymodified' gcc -O2 -I. -Ilinux-include -DHAVE_MALLOC_H=3D1 -DHAVE_ETHER_HOSTTON=3D1 -DHAVE_STRERROR=3D1 -DHAVE_NET_IF_ARP_H=3D1 -c ./pcap-linux.c gcc -O2 -I. -Ilinux-include -DHAVE_MALLOC_H=3D1 -DHAVE_ETHER_HOSTTON=3D1 -DHAVE_STRERROR=3D1 -DHAVE_NET_IF_ARP_H=3D1 -c ./pcap.c

This will appear as really complex to a new user (or even a more experienced user with little programming knowledge), as it is simply reporting on what the compiler is doing. As long as the compiler does not report any errors, it will probably be fine.

Once the make program is finished building the software, it is time to install it in it's proper location. If you are logged in as a normal (non-root) user, it is now time to become root using the su (Switch User) command.

$ su Password: bash#

We are now root, and have full control of our system. We will execute the 'make' command again, but this time will add an argument to install our software:

bash# make install

The make program will now give us more progress, describing how it is going about installing software. Once this process is finished, we can now run our application (as described in the README) file.

The ability to compile software yourself is one of the ways Linux gets its superiority. A more experienced user can modify the software however he or she likes. Another good thing, however, is that a new user is not obligated to compile software his or herself. Most packages will come pre-built in a format easily recognized by your distribution. Information on this can usually be found where you found the application itself.





   Page 1 of 1