General steps for compiling source code and installing software

Source: Internet
Author: User



The difference between installing software using package management and compiling source code is that most of the software provided by package management (taking RPM as an example) only retains some common functions, if we need to use other features of the software without the RPM package, we need to compile the source code. Software installed by compiling source code can freely choose to install those functions, while RPM is fixed. The source code installation and selection function is flexible, and the RPM package is easy to install. In most cases, software is released in source code mode faster than RPM packages.

Source code acquisition method,


Compiling source code to install software depends on the development environment. Compiling C Programs requires the GCC compiler. Compiling C ++ requires the GCC-C ++ compiler. If not, you need to install it. Use Yum or rpm for installation.


Make tool, in order to maintain the source code conveniently, a software with a little more code may be divided into multiple files, and there is a dependency between them during compilation, and there must be a sequence of order during compilation. Program developers will use the project management tool (make) to provide a configuration file for make. This configuration file describes how make calls GCC and the sequence of compilation of these files.


Configure script file. In this article, the script will check the compiling environment and manually set the features of the software to be started and installed in that directory.


The options supported by configure are slightly different for each software. Commonly used

-- Help for help

-- Prefix =/path specifies the software installation path.

-- Sysconfdir =/path specifies the directory where the configuration file for software installation is located

-- Enable-feature names enable a feature or option. Enabling a feature may depend on an additional development environment.

-- Disable-feature name disables a feature

-- With-function or -- with =/lib/filename specifies the dependent function or file in a specific path.

-- Without-Function

The sequence of compiling and installing source code,

Decompress the downloaded software package --> Cd to the decompressed directory -->./configure to set the compilation options --> make (compile the program) --> make install (put the edited program in the specified directory)


Example: Compile and install nginx Software

#./Configure -- prefix =/usr/nginx -- conf-Path =/etc/nginx. conf

Error

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJOsCB-wNAAAEqZ-tihVk404.jpg "style =" float: none; "Title =" 1.png" alt = "wKioL1PJOsCB-wNAAAEqZ-tihVk404.jpg"/>

./Configure -- prefix =/usr/nginx -- conf-Path =/etc/nginx. conf -- without-http_rewrite_module

Confirm no error

# Make

Confirm no error

# Make install

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJOaXBMeUAAARkC_27Y5o167.jpg "style =" float: none; "Title =" 2.png" alt = "wkiom1pjoaxbmeuaaarkc_27y5o167.jpg"/>


View the configuration file directory

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJOsCDvBkLAAD1yaUm6JI966.jpg "style =" float: none; "Title =" 3.png" alt = "wkiol1pjoscdvbklaad1yaum6ji966.jpg"/>

View nginx installation directory

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJOaXxMjMPAABMuHbXna0340.jpg "style =" float: none; "Title =" 4.png" alt = "wkiom1pjoaxxmjmpaabmuhbxna0340.jpg"/>


Start the nginx Service

#/Usr/nginx/sbin/nginx &

# SS-tnlp

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJOsDh7vrFAAERo-nT_To434.jpg "style =" float: none; "Title =" 5.png" alt = "wKioL1PJOsDh7vrFAAERo-nT_To434.jpg"/>


To make nginx like a program installed by rpm, do the following:

Define the PATH environment variable and create an nginx. Sh file in/etc/profile. d. The content is export Path = $ path:/usr/nginx/sbin.


Add man manual to the/etc/man. conf file

Man/manual location



If other programs depend on the development environment of the program, you need to export the library and header file of the program.

Edit/etc/lD. So. conf. d/nginx. conf and add the path of the library file to the file. Then execute ldconfig to trigger the location where the new library file is located. The exported header file can only create links and link the directory of the library where the software is located to/usr/include.









This article from the "red face easily die lofty sentiments long" blog, please be sure to keep this source http://wukui.blog.51cto.com/1080241/1440093

General steps for compiling source code and installing software

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.