The Linux learning Path is compiled by the software

Source: Internet
Author: User

Software Compilation Installation

We know that when installing a certain software, some of the programs or features that we do not need to install are installed on the system, and the program or feature we need is not installed, or there are some loopholes in the software, and so on, we need to modify the source code of the software, and then recompile the production of a binary file, The last user can install this binary file.

We know that the system really recognizes the file is only a binary file, and the original code of a software is a program, and this kind of program is for people to see, the system is not recognized, so in order to allow the system to recognize the content of this source code, the original code must be converted to the system can be recognized by the binary program. The original code is converted to a binary file that needs to be done with the help of a compiler.

The so-called compiler is to parse the program code into a system to recognize the binary program.

So we can understand the concept of primitive code, compiler, and binary program.

Source code: That's what we always call the program code

Compiler: Converting the original code to a binary file

Binaries: A program that the system can recognize

The flowchart for compiling the source code into a binary file is:

650) this.width=650; "title=" Qq20140722202813.png "src=" http://s3.51cto.com/wyfs02/M00/40/4A/wKioL1POWhjzqcU5AABf _a6vdyk794.jpg "alt=" Wkiol1powhjzqcu5aabf_a6vdyk794.jpg "/>

of which in most Linux Distribution The compiler that is most used in GCC up. In the process of compiling, we may invoke some of the existing library files, which can be used to accomplish certain functions. Remember, the library cannot be executed automatically, and the contents of the library file will only work if it is called. And the function library is divided into static and dynamic function libraries.

The following steps are included throughout the compilation process:

First, prepare the development environment or compile the environment.

This compilation environment mainly includes the following points:

1. is there a suitable compiler to compile the software's original code, such as whether there is GCC and other compilers

2. whether the library of functions required by the software is present, and the other software that the software relies on

3. whether the software is suitable for the operating system

4. the header file for the kernel ( header include ) is present

If the compilation environment is not compliant, an error may occur during the installation so that the installation fails

Second, installation "Development Tools" and the "Development Libraries"

Third, Compiling and installing

actually use GCC A similar compiler to compile the program is more complicated, except that each program needs to write a piece of code, but also

need to write the final link to the program. And we can simplify the entire compilation process by using make, the project management tool.

Make the working mechanism : Make is actually a program, when Make when executed, Make will search in the current directory

Makefile (or Makefile this text file, which records the details of how the original code was compiled . and makefile

This file is made up of Configure generated by this program. Configure This program is primarily used to detect the compilation environment and the

allows the user to select the compilation attribute in the process. If the detection is unsuccessful, then the installation will not succeed. when the inspection environment is complete, it will

Production Makefile file.

Therefore, the compilation and installation can be divided into the following steps:

1. The default source code file is *.tar.gz , so you need to use the Tar command to extract the extracted files and place them in the /usr/local/src directory under

2. Use CD command to switch to the directory where the source code resides

3. Run Configure This program detects the compilation environment and generates Makefile file

in the Run Configure This program, you can add some parameters, these parameters can change some of the compilation features. For example:

--help: Show all compilation parameters

--prefix=/path/to/somewhere: Specify the location of the generated files after the software installation

--conf-path=/path/to/somefile: Specify the configuration file for the software

--sysconfdir=/path/to/somewhere: Specify the directory for the configuration file

4 , using Make command According to Makefile the parameters in the file are compiled

5 , using Make Install command to install

We know that the composition of a program generally includes: binary programs, libraries, configuration files, help files, etc.

If this binary is to run, it must be run with the full path name because PATH The binary file path is not in the variable. or modify the path variable directly so that it can recognize the binary file path of the program.

Modify PATH There are two methods of variables:

First, Direct Modification /etc/profile files, modifying PATH the value of the variable

Second, in the /ETC/PROFILE.D directory to create a . SH file for name suffix, add a row here

Export PATH = $PATH:/path/to/somefile

The library file is stored by default in the /lib,/usr/lib directory. To add an additional search path you can do this:

in the /etc/id.so.conf.d/ are created in . conf The file to be appended, and then the path to be added is written directly in this file;

Use Idconfig command to notify the system to re-search the library file

where - v: Shows the process of re-searching the library file

Header file: Output to System

Default:/usr/include

Add header File search path, using links to:

/usr/local/tengine/include//usr/include/

Two different ways:

ln-s/usr/local/tengine/include/*/usr/include/ or

Ln-s/usr/local/tengine/include/usr/include/tengine

The help file generated by the software is stored in the specified directory by default. Mans directory. You can do this in order to use the man command query:

1 , man-m/path/to/man_dir COMMAND

2 , in /etc/man.config Add a MANPATH

This article from the "Linux Learning Path" blog, declined reprint!

The Linux learning Path is compiled by the software

Related Article

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.