Linux Guide/Building software

From Wikibooks, open books for an open world
< Linux Guide
Jump to: navigation, search

Sometimes it is necessary or desirable to build a program's executable binaries from the source code provided by the programmer or programming team. Perhaps there are no pre-built binaries available for your system, or perhaps you have some special configuration or optimization requirements that are not available in pre-built form.

The source code for a program is normally provided in a single archive file and the first step is to download this file, or locate and copy it from (for example) a CD or DVD disk.

Once you have obtained the source code for a program there is a typical sequence of steps normally required: (note: anything in square brackets you replace with whatever is applicable)

  • Open a command line (console) session
  • cd to the directory containing the archive: cd /root/Desktop/[filename.tar.gz]
  • Decompress
    1. If the archive ends in .tar.gz or .tgz then type in this command: gzip -d [filename.tar.gz]
    2. If the archive ends in .tar.bz then type in this command: bzip2 -d [filename.tar.bz2]
  • Separate the archive by typing in: tar -xvf [archivename.tar]
  • cd to the uncompressed archive by typing in: cd [progname]

At this stage, you have unpacked the files from the archive and they should now be examined for any documentation files, typically called README or INSTALL. These files will normally give specific installation and configuration instruction for the program. These typically consist of:

  • configure it by typing in: ./configure
  • make it: make

For the final installation steps, it is usually necessary to have root (super user) privileges. These can be obtained by issuing the su command and entering the password when prompted.

  • install it: make install
  • now run it by typing: [progname]