Source code is a computer program in human readable form. However, the machine cannot execute source code. The code must be compiled into machine code before it is useful. On Linux, the "make" build system is the most common one, and this how-to works for almost all Linux source code packages.

Steps

  1. It will most likely be in the form of a "tarball" and have a file extension of .tar, .tar.bz2, or .tar.gz. Sometimes a .zip file will be used instead however.
  2. Unpack the downloaded code- for .zip files use "unzip your file", for .tgz or .tar.gz use "tar -zxvf yourfile"; for .bz2 use "tar -jxvf yourfile"; or extract your files graphically.
    Advertisement
  3. You do this by typing cd followed by a space and then the name of the directory. (Remember that directory names in Linux are case sensitive).
  4. /configure" to configure the source code automatically. Arguments such as " --prefix=" can be used to control the install location. This checks that you have the right libraries and versions.
  5. An executable for the program will be created in the bin directory inside the source code directory.
  6. Advertisement

Expert Q&A

Ask a Question

      Advertisement

      Video

      Tips

      • On multicore processors, you may compile in a multithreaded fashion using make -j3 , replacing 3 with however many threads you want to use.
      • If the build fails for any reason, before you attempt to build again you should run "make clean" to remove all files left behind by the original build attempt. These files may make your second attempt fail because they exist.
      • Unless you specify a prefix, the code will automatically install in /usr .
      Show More Tips
      Advertisement

      Warnings

      • Compiling can take hours.
      • Compiling and replacing critical system components can cause problems if you recompile and reinstall them. Know what you are doing.
      • Some source packages don't have configure files or even make files. In this case, just type `make' at the prompt and see what happens.
      Advertisement

      About this article

      Thanks to all authors for creating a page that has been read 134,120 times.

      Is this article up to date?

      Advertisement