[Linux journey] Part 4 Lesson 5: source code compilation and easy installation

Source: Internet
Author: User

[Linux journey] Part 4 Lesson 5: source code compilation and easy installation

 

 

Introduction

1,Part 4 Lesson 5:Compilation of source code to facilitate installation

2,Part 4 Lesson 6:DNS and domain name

 

Compilation of source code to facilitate installation

 

This course is relatively easy. After all, is it just a New Year (2015-2016)? How can the new year make everyone one of the top two ~ How can small editors be so bad? Is this a small editor? (Yes -_-#).

 

In previous courses ([Linux exploration journey] Part 2 Lesson 7: software installation, things like this), we have learned how convenient it is to install software under the Ubuntu Linux release, you can easily use apt-get. This method allows us to download and install most of the software.

 

Similar to other Linux distributions.

 

However, some software is not included in the software warehouse, so we can only install it manually, that is, we can only download the source code of the software and compile it to generate executable files.

 

This method is sometimes complicated. We need to download the source code first. The downloaded source code is usually a compressed package, decompress the compressed package, configure the package, compile the package, and then install the package. I hope this course will allow you to apply some of the previous knowledge to practice. We will explore software compilation step by step.

 

First try to find the deb installation package

 

First, we have to declare that the software package installation and other knowledge points involved in this part are based on the Debian Linux release, including Ubuntu.

 

Other Linux releases, such as Fedora, Redhat, CentOS, and so on, which are not in the Debian family. In fact, the method for installing software is similar, that is, the command used between each Linux release is different, and the software package name is a little different.

 

Most of the software in Ubuntu can be found in the software repository. You only need to use the apt-get command to install them. However, a small number of newer or still under development or not well-known software has not been included in the software repository, then you can't use apt-get to get it.

 

In this case, things will become more complicated. In Windows, to install a software, we need to first go to the software's official network and download the installation file ending with .exe.

 

However, programmers who write software for Linux systems generally do not create installation files similar to those in Windows. Why? Are Linux programmers very lazy?

 

Yes, Linux programmers are very lazy. Joke. The reason is that Linux has a wide variety of releases (such as Ubuntu, Fedora, CentOS, SUSE, and so on), and each release has a different version number. There are also different processor types (32-bit and 64-bit CPU, ARM architecture, Intel architecture, and so on) to adapt, unlike Windows because it is defined by Microsoft, there are 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 warehouse, we can try to find the installation package with the suffix ". deb (Debian)" on the official website of the software .. The deb installation package can only be used for Debian operating systems, including Ubuntu. The Redhat family (including Fedora) uses the installation Package suffixed with. rpm (indicating Redhat Package Manager.

 

However, there is a software that can help convert the rpm installation package to the deb installation package. This software is alien (meaning "aliens", haha ):

 

# Alien is not installed by default, so you must install it first.

sudo apt-get install alien

 

# Convert rpm to deb. A xxxx. deb with the same name will be generated after the conversion.

sudo alien xxxx.rpm

 

# Installation. Note that the deb package converted from alien cannot be installed smoothly in 100%, so it is best to use deb directly if you can find deb.

sudo dpkg -i xxxx.deb

 

If you have the honor to find the deb installation package of the software on the Internet, download the package and double-click the installation package (or use the following command line: sudo dpkg-I xxxx. deb ).

 

Then a window will pop up, asking if you are sure to install it and selecting "Install ".

 

If there is no error in the installation process, it is good. If an error occurs, it may be caused:

 

Maybe the deb installation package you downloaded does not match your computer environment. The number of digits may be wrong. 32-bit and 64-bit are different.

Maybe you have not installed those dependent software. Because the apt-get tool will automatically download various dependent software, we do not need to do it ourselves. But now you need to install the missing dependent software by yourself. You can install the software as prompted.

 

If you cannot find the deb installation package, you can only: Get the source code of the software, and then break it (Oh, No, It is compiled by yourself ).

 

Next let's take a look at how to start from the source code until the compilation and installation are complete.

 

There is no other method. Select compile and install

 

If the software you want to install is not in the software warehouse, and you cannot find the corresponding deb installation package on the Internet, you can only go back to the Stone Age and install it by compiling the source code.

 

What is compilation?

 

In short, compilation is the process of converting the source code of a program into an executable file. For example, the raw materials used for making cakes (such as eggs and flour) are source code, and the final cake is an executable file. In this metaphor, compilation is the process of making a cake.

 

If it is complicated, it cannot be said.

 

Most Linux programs are open-source. We can easily obtain their source code and compile it into executable files suitable for our computer and operating system attributes.

 

The steps for compiling and installing software are different depending on the software. The compilation and installation of some software is very complicated and may drive you crazy (especially some non-standard and non-mainstream software) and requires a lot of preparation work. The installation steps are described in the general installation manual. Even so, sometimes it will make you bigger, and you can only solve small errors one by one. There is no way. Who makes programmers love it? What is the significance of a life without tossing.

 

Compile the program step by step

 

You need to install the compilation tool before compiling. In Ubuntu, there is a way to install the compilation-related tool at one time, that is, build-essential (build refers to "build" or "compile, "essential" means "necessary", as its name implies, "necessary tools for building/compiling"). Run the following command to install:

sudo apt-get install build-essential

 

A command is done, and the mighty and handsome display of Linux is exhausted. Windows has basically been crying in the toilet ~ (The Daily black Windows task is completed again, coke)

 

 

After installing the basic tools required for compilation, we can start the project.

 

Let's use a small software as an example. This software is htop. We have learned the top command before. It can view various processes running on the computer, memory usage, cpu usage, and so on. It is similar to the Job Manager in Windows. Htop is a small software similar to top.

 

Although the htop software can also be installed from apt-get. However, to demonstrate the compilation and installation process, we can use it (poor baby ).

 

The first step to go to the software Official Website: http://hisham.hm/htop?

 

 

Then click on the left [Downloads/Git], the current software development source code is hosted on Github, Github related page: https://github.com/hishamhm/htop (you can go up to see, familiar with the world famous Github) <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Authorization + authorization/Ww/Ljxyr205rfF1No8L3A + DQo8cD4mbmJzcDs8L3A + DQo8cD48YSBocmVmPQ = "http://hisham.hm/htop/releases" target = "_ blank" title = "\"> http://hisham.hm/htop/releases

 

Go to the latest stable version: 1.0.3 directory

 

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

 

Download the file

htop-1.0.3.tar.gz

 

After the download, We decompress the package using the previously learned decompression method:

tar zxvf htop-1.0.3.tar.gz

 

Decompress and generate 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 many files. We don't need to care about these details.

 

Among the many files, we are interested in one file:

configure

 

Configure is the meaning of "configuration" in English. As the name suggests, it is the preparation of some configuration for software compilation.

 

Run it:

./configure

 

Configure will analyze your computer and check whether all necessary tools are installed. It takes some time to execute it because it requires a lot of detection.

 

An error occurred during result Detection:

 

 

The error is:

 

-Lncursesw not found

 

The prompt message is:

 

Error: You may want to use -- disable-unicode or install libncursesw

 

"Error: you may want to use the -- disable-unicode parameter or install libncursesw"

 

First, I tried to install libncursesw on the Internet. Directly use the first suggestion: Use the -- disable-unicode Parameter

 

Run configure again (with the -- disable-unicode parameter)

./configure --disable-unicode

 

This will be okay.

 

Then we can start compiling. Run the make command:

make

 

No error. The compilation is complete.

 

Then, run the make install command (add sudo to install the software with the root permission ):

sudo make install

 

No problem. Installation is complete. Run the htop software and try:

htop

 

 

Success! Close the work ~

 

The next lesson will be difficult. Let's take a good look at the ins and outs of IP addresses, domain names, and DNS domain name resolution systems.

 

Summary

 

  1. Most Linux releases can be installed with the package management tool apt-get (for Debian ).

    Some software cannot be installed through apt-get, because it is not included in the Ubuntu software repository. In this case, we can try to find the deb installation package of the software on the Internet.

    If neither method works, we can only compile and install the method from the source code. The general steps are as follows:

     

    1. Download the source code of the program from the Internet (usually compressed into the .tar.gz format ).

      Decompress the compressed package (tar zxvf xxx.tar.gz)

      Run the configure file in the decompressed Folder:./configure

      Run make to compile

      Run sudo make install to complete installation

       

      Part 4 Lesson 6 advance notice

       

      Today's class is here. Come on!

      In the next lesson, we will learn:DNS and domain name

    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.