Source code compilation and installation of Linux package management

Source: Internet
Author: User
Tags automake

Environment

OS:CentOS 6.5 64位
示例软件:nginx 

Starting from source code

In the Linux environment, most of the software is developed in C + +, there is no difference between the software compiled and installed in the two languages, let's take a look at the software source structure in a Linux environment.

[[email protected] nginx-1.6.1]# Lsauto changes changes.ru conf Configure contrib HTML LICENSE man README src

After we extract each package, go to the package directory, the first thing should read the following readme and Instsll file, this is a good habit. From the source package of many sources, we will find a problem, we learn C language, we write a small program is a source file, but there are many, and this multiple source files are interdependent, which makes it impossible for us to compile with GCC. This leads to a series of tools such as make, which are related to package compilation. In order to illustrate this series of tools, we first come back from configure, we have just said that the source package contains a lot of source files, these source files are the existence of a certain interdependence, the relationship is who to maintain, that is the makefile file, The compilation relationships of these source files are defined in the Makefile file to guide the make command to work. So where does this makefile file come from, this is a text file that can be handwritten, but on the one hand we do not necessarily have this ability, on the other hand handwritten makefile is a meaningless thing, because makefile can be generated automatically. Let's take a look at how the makefile file is automatically generated, and the auto-generated makefile file requires two files, Configure and makefile.in, respectively, continue to trace the problem, where configure files and makefile.in files come from, configure files are automatically generated by the autoconf command, makefile.in is automatically by the Automake command Generated by the. Let's comb the relationship.

  autoconf command  ---->configure file      makefile.in file  <----  Automake Command                               |                      |                                |                      |                           -----------------------                                 | |                                  \/  sourse  code ----> make command  + makefile file  -----> executable file

By combing the relationships we can see that everything is done to generate the makefile file, and the package provides the configure file, which is why, why not provide the makefile file directly. The reason is simple, everyone in compiling software has some of their own personalized settings, these settings will be in configure this step, and then configure file based on the given settings and system platform features to generate makefile files.

Get started.

To understand the above theoretical knowledge, the following hands-on things are very simple, in general, the source code compiled installation software is divided into three steps:

    • ./configure: This step is actually a lot of options can be specified, that is, personalization, you can use ./configure --help to see the options you can use, the most common is to --prefix=PATH specify the installation path.

    • Make: This step does not need to use any option, as long as the previous step smooth execution, this step is generally no accident, everything is automatic execution, silently wait for it.

    • Make install: This step is essentially copying the results compiled from the previous step to the directory we specified.

Example:
[[Email protected] nginx-1.6.1]# ./configure --prefix=/usr/local/nginxchecking for &NBSP;OS+&NBSP;LINUX&NBSP;2.6.32-431.EL6.X86_64&NBSP;X86_64CHECKING&NBSP;FOR&NBSP;C&NBSP;COMPILER&NBSP, .....  found+ using GNU C compiler+ gcc version: 4.4.7 20120313  ( red hat 4.4.7-4)   (GCC)  checking for gcc -pipe switch ...  Foundchecking for gcc builtin atomic operations ... foundchecking for  c99 variadic macros ... found# omitted a number of lines here, are doing checkingchecking for zlib  library ... foundcreating objs/makefileconfiguration summary+ using system  Pcre library+ openssl library is not used+ md5: using system  crypto library+ sha1: using system crypto library+ using system  zlib librarynginx path prefix:  "/usr/local/nginx" nginx binary file:  "/usr/local/nginx/sbin/nginx" nginx configuration prefix:  "/usr/local/nginx/conf" nginx configuration file:  "/ Usr/local/nginx/conf/nginx.conf "ginx pid file: "/usr/local/nginx/logs/nginx.pid "nginx  error log file:  "/usr/local/nginx/logs/error.log" Nginx http access log file :  "/usr/local/nginx/logs/access.log" nginx http client request body temporary  files:  "Client_body_temp" nginx http proxy temporary files:  "Proxy_temp" nginx http fastcgi temporary files:  "Fastcgi_temp" nginx http uwsgi  temporary files:  "Uwsgi_temp" nginx http scgi temporary files:  "Scgi_temp"

Here, the./configure file completes the Environment check, option settings, now we have a makefile file in the source package, the next step is to point to the make command.

[[email protected] nginx-1.6.1]# make# a bunch of messy output [[email protected] nginx-1.6.1]# make install# various create directories, copy files.

By this time, the software compilation installation is over.

Deal with the funeral

There's a lot more work to do after the package is compiled and installed.

    • Add path Path: The default path path is not found in the executable file we installed, so we want to add it manually.

    • To add a man document search path: This allows us to modify the man's configuration file.

    • Add a search path to the library file and header files: For example, the Apache server, after the installation is completed will generate a lot of library files, these library files in other programs may be dependent, the common practice is to do a link to the Lib directory down.


This article is from the "Flower Full Floor" blog, please make sure to keep this source http://becaning.blog.51cto.com/7548193/1569012

Source code compilation and installation of Linux package management

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.