Download ArticleDownload Article

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.

  1. How.com.vn English: Step 1 Download the source code for the program or driver from the Internet or other media.
    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. How.com.vn English: Step 2 Unpack the downloaded...
    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. How.com.vn English: Step 3 In the terminal, move into the newly extracted directory.
    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. Step 4 Run the command ".
    /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. Step 5 Once configured, run "make" which does the actual compiling (this can take anything from a few seconds to many hours).
    An executable for the program will be created in the bin directory inside the source code directory.
  6. Step 6 To install the program- run "make install".
  7. How.com.vn English: Step 7 You have compiled and installed the program source code.
  8. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      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
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      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

      Tested by:
      How.com.vn Technology Team
      How.com.vn is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 17 people, some anonymous, worked to edit and improve it over time. This article has been viewed 133,520 times.
      How helpful is this?
      Co-authors: 17
      Updated: September 5, 2021
      Views: 133,520
      Categories: Linux
      Thanks to all authors for creating a page that has been read 133,520 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement