"Linux Exploration Tour" Part IV lesson Five: Source code compilation, installation convenience

Source: Internet
Author: User


Content Introduction

1,< Span style= "padding:0px; margin:0px "> Part IV lesson five: source compilation, installation convenience

2 , Part VI lesson: dns and domain name, what to do


source code compilation, installation convenience


This lesson is relatively easy, after all, just across the year (2015-2016), how can the new Year let everyone a first two big ~ how could it be so bad? Is this the kind of person? (yes,-_-#).


The previous course ("Linux Quest" part seventh: Software installation, powering up), we've seen how easy it is to install software under the Linux release version of Ubuntu, which can be easily done with the Apt-get tool. This way allows us to download and install most of the software.


Other Linux distributions are similar, follow.


However, some software is not included in the software warehouse, then we can only manually install, that is, only download the source code of the software, compiled to build the executable.


This approach is sometimes more complicated. We need to download the source code first, the downloaded source is usually a compressed package, unzip the package, then configure, then compile, and then install. I hope this lesson will allow you to apply some of the knowledge previously learned to practice, we step-by-step to explore the compilation of software.


First try to find the Deb installation package


First of all, we have to state: this part of the package is related to the installation of knowledge points are based on the Debian family Linux distribution, including Ubuntu.


Other Linux distributions that are not Debian, such as Fedora,redhat,centos, and so on. In fact, the way to install the software is much the same, that is, each Linux distribution between the use of different commands, the package name is a little different.


Most of the software under Ubuntu can be found in the repositories, and you can install them with the Apt-get command. However, there are a few relatively new or still in development or not very well-known software, is not included in the software warehouse, then you can not use Apt-get to obtain.


In this case, things can get a little more complicated. Under Windows, to install a software, we are accustomed to first go to the software's official website, and then download the installation file at the end of the. exe.


However, programmers who write software for Linux systems generally do not create files that resemble those installed in Windows. Why is it? Are Linux programmers lazy?


Yes, Linux programmers are very lazy. I'm joking. Because Linux has a very diverse distribution (such as ubuntu,fedora,centos,suse, etc.), each release has a different version number. And there are different processor types (32-bit and 64-bit CPU,ARM architecture, Intel architecture, etc.) to fit, unlike Windows because it is Microsoft's own definition, not too many variables. Therefore, it is almost impossible to create an installation file for each type of Linux.


When the software we are looking for is not in the Ubuntu software repository, we can try to go to the official website of the software to find the suffix of the. Deb (for Debian) installation package: The Deb installation package can only be used for Debian family operating systems, including Ubuntu. The Redhat family (including Fedora) uses the installation package with a suffix of. RPM, which represents Redhat packages Manager.


But there is a software that can help convert the RPM installation package to the Deb installation package. This software is Alien (is "alien" meaning, haha):


#alien默认没有安装, so install it first

sudo apt-get install Alien


#将rpm转换为deb, a xxxx.deb with the same name will be generated when completed

sudo alien xxxx.rpm


#安装. Note that the alien conversion of the Deb package does not guarantee 100% smooth installation, so you can find Deb best to use Deb directly

sudo dpkg-i xxxx.deb


If you're lucky enough to find the software's Deb installer directly online, download it and double-click the install package (or use the command line above: sudo dpkg-i xxxx.deb).


Then a window pops up and asks if you are sure of the installation, select "Install".


If the installation process is not wrong, that's fine. If there is an error, it is generally possible because:


    1. Maybe you downloaded the Deb installer that doesn't fit your PC's environment. Maybe the number of digits is wrong, 32-bit and 64-bit are different.

    2. Maybe you didn't install those dependent software. Because the Apt-get tool will help us to automatically download a variety of dependent software, so we do not need to do it ourselves. But now you need to install the missing dependencies on your own, depending on the information you are prompted for and what you are missing.


If you can't find the Deb installer, you can only: Get the source code of the software and then break it yourself (oh, no, compile it yourself).


Let's take a look at how to start from the source code until the installation is complete.


There is really no other way to choose to compile the installation


If the software you are installing is not in the software repository, and you cannot find the appropriate Deb package on the Web, you can only go back to the Stone Age and install it by compiling the source code.


What is compilation?


Simply put, compiling is the process of converting a program's source code into an executable file. Just like we make cakes, the raw materials used (such as eggs, flour, etc.) are the source code, and the final cake is the executable file. In this analogy, compiling is the process of making a cake.


If you say it in a complicated way, you can't finish it.


Most Linux programs are open source, and we can easily get their source code and compile it into executable files that fit our computer and operating system properties.


The steps to compile and install the software differ according to the software. The compilation and installation of some software is very complex and may make you mad (especially for non-standard, non-mainstream software) and requires a lot of preparation. However, the general installation manual will explain the detailed installation procedures. Even so, sometimes it will make you relatively big head, can only solve the small errors encountered. No way, who let programmers love toss it, do not toss the meaning of life, wood ah haha.


Step-by-step compilation program


Before compiling, you need to install the compiled tools. In Ubuntu there is a way to install a one-time compiler-related tools, that is build-essential (build is "build" or "compile" meaning, essential is "necessary" meaning, as the name implies "to build/compile the necessary tools"), Run the following command to install:

sudo apt-get install build-essential


A command is done, Linux is mighty handsome. Windows June has basically been crying out in the toilet ~ (daily black Windows quests are finished again, Koko)




After installing the basic tools needed for compiling, we are ready to start.


Let's use a little software as an example to explain it. This software is htop. Before we learned the top command, it was able to see the various process states running on the computer, how much memory was consumed, CPU usage, and so on, a bit like Task Manager in Windows. Htop is a small software similar to top.


Although htop this software can also be installed from the apt-get. But in order to demonstrate the process of compiling the installation, we took it to the axe (poor baby).


The first step to the software's official website: http://hisham.hm/htop/?



Then click on the left [Downloads/git], the current development of the software source code hosted on GitHub, GitHub related page: Https://github.com/hishamhm/htop (can go up to see, Familiarize yourself with the world-famous GitHub)


But the stable release version is not on GitHub, but is stored in the tar.gz compressed package format


Http://hisham.hm/htop/releases


We enter the latest stable version: 1.0.3 version of the catalogue


http://hisham.hm/htop/releases/1.0.3/


Download the file

Htop-1.0.3.tar.gz


After downloading, we use the decompression method we learned before:

Tar zxvf htop-1.0.3.tar.gz


The decompression has become the htop-1.0.3 directory.


Then go to the directory:

CD htop-1.0.3


If you use the LS command to list files, you will find that there are many, do not be afraid. We don't need to care about these details.


In a number of files, we are interested in a file:

Configure


Configure is the English "configuration" meaning, as the name implies that the software is compiled to do some configuration of the preparatory work.


We run it:

./configure


Configure this program will analyze your computer and verify that all the necessary tools for compiling are installed. It takes some time to execute because there is a lot of testing to do.


Result detection error occurred:




The error is:


No-LNCURSESW found.


The prompt information is:


Error:you want to use--disable-unicode or install LIBNCURSESW


It means: "Error: You may want to use the--disable-unicode parameter or install LIBNCURSESW"


First small to go to the Internet to find the installation of LIBNCURSESW method, are not, so for the sake of quick, don't toss. Directly with the first recommendation: with the--disable-unicode parameter


Rerun configure (plus--disable-unicode parameter)

./configure--disable-unicode


It's not going to be a mistake.


Then we can start compiling. With the Make command:

Make


There is no error, the compilation is complete.


Then the final step is to install with the Make install command (you need to add sudo to install the software with root privileges):

sudo make install


No problem. Installation is complete. Then run the Htop software to try:

Htop




It's done.


The next lesson will be more difficult, let's explore the ins and outs of IP address, domain name and DNS domain name resolution system.


Summarize


    1. Most Linux distribution software can be installed with the Package management tool Apt-get (for the Debian family).

    2. Some software cannot be installed through Apt-get because it is not included in Ubuntu's software repository. In this case, we can try to find the software's Deb installation package online.

    3. If the first two methods are not working, we can only choose the method of compiling the installation from source code. The general general steps are as follows:


    • Download the program's source code from the Web (usually packaged in a. tar.gz format).

    • Decompression Pack (tar zxvf xxx.tar.gz)

    • Run the Configure file in the extracted folder:./configure

    • Run make to compile

    • Run sudo make install to complete the installation


fourth part sixth lesson trailer


Today's class will come here, together refueling it!

Next lesson we learn:DNS and domain names, a probe into the

"Linux Exploration Tour" Part IV lesson Five: Source code compilation, installation convenience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.