linux-Source Software Installation method

Source: Internet
Author: User

Many of the software under Linux is published through the source package, so that for the end user, although compared to the binary package, configuration and compilation cumbersome point, but it is much better portability, for different architectures, software developers often only need to publish the same source package, Different end users can be compiled to run correctly, which is very in line with the design philosophy of C language, once written, compiled everywhere, and common binary packages, such as RPM and Deb, software developers must be customized for each specific platform of a special package, This through the extension of the rpm file suffix can be the beginning, such as ppc,sparc,i386, do not make too many statements here, in fact, the source code installation software far less complex than many friends imagine, below I am here as detailed as possible to do some statements, if there is falsehood, welcome friends to shoot Bricks!

Specific steps to install:

$ tar zxvf XXXX.tar.gz (or tar jxvf XXXX.tar.bz2) $ cd xxxx$./configure$ make# Make Install
$ make clean

Use to clean up temporary files after installation is complete

# make Uninstall

Copy Code

Used to uninstall software

Extract:
The most common source of two types of packages (XXXX.tar.gz or XXXX.tar.bz2), in fact, these source packages are compressed by 2 tools, tar.gz end of the file used by the tool is tar and gunzip, The tar.bz2 end-of-file tool is tar and bzip2, because tar can only package multiple files without compression, and GZ and bz2 are just the opposite, only able to compress a single file, In this way, our common source package is actually through the tar first to package the different source files, and then by gunzip or bzip2 compressed after the release, of course, these two steps can be implemented by a command:

$ tar zcvf XXXX.tar.gz xxxx (or tar jcvf XXXX.tar.bz2 xxxx)

Copy Code

The relevant commands for decompression are as follows:

$ tar zxvf xxxx.tar.gz$ tar jxvf XXXX.tar.bz2

Copy Code

./configure:


Unzip the completion of the official start to install (add a little, before starting configure, if necessary, please use the Patch tool for the source code corresponding patches), first jump to the source of the extract directory, it is known that Start configure before or should carefully read the source directory of the Readme or install files, a lot of installation considerations here are listed, configure is actually a script file, in the current directory type "./configure", The shell will run the Configure script under the current directory, one thing must be explained, in the entire configure process, in fact, the compilation has not been done, configure is only to do the compilation related preparation, it mainly to your current work platform to do some dependency check, For example, if the compiler is installed, if the connector is present, if there is no error in the detection process, you are fortunate that the Configure script will generate another file to be used to compile the link in the current directory makefile, of course configure support and its rich command line parameters, You can type "./configre--help" To get specific information, perhaps the most commonly used is:

$./configure--prefix=/opt/xxx

It is used to set the installation directory of the software.

Make
If the Configure process is completed correctly, then in the source directory, the corresponding makefile file will be generated, the makefile file simply includes a set of file dependencies and the relevant steps to compile the link, in fact, the actual compilation of link work is not made, Make is just a generic tool, and in general it calls the appropriate compiler to compile all the source code dependent on the current software, generate all the relevant target files, and finally use the linker to generate the final executable program based on the rules in Makefile:

$ make


Make install:
When the above two steps are completed correctly, representing the process of compiling the link has been completely finished, the last thing to do is to install the executable program to the correct location, in this step, the normal user may not have the relevant directory operation permissions, temporary switch to root is a good choice, "install" Just a label in the makefile file, "make install" means that the Make tool performs all related operations under the "Install" label in the makefile file, if it is not used in the Configure stage--prefix=/opt/xxx "Specifies the application's installation directory, then the application will generally be installed by default to/usr/local/bin, if/usr/local/bin already exists in your path, then the installation has basically ended:

#make Install


Make clean:
Make uninstall:
These two steps are only the follow-up of the installation, it must be noted that "clean" and "Uninstall" is also the corresponding two labels in the makefile file, the time to perform these two steps makefile file necessary to retain, "make clean" To clear some of the temporary files during the compilation connection, "Make uninstall" is to uninstall the relevant application, like make install, the make uninstall also need to switch to root execution, but "uninstall" Marking in a lot of makefile are omitted, friends can fully themselves in the corresponding makefile file to find out.

Why?
Here I try to explain the reasons for the existence of these steps, from the C language perspective, a program from the source to the correct generation of related executables, the following parts are essential: source files, compilers, assemblers, connectors, relying on the library, through the above steps, friends should already know, There is only one step to actually perform the compile link operation (make), what are the reasons for the other steps?
One thing is certain, I use the C language on my own computer to write some of the small programs, and do not use the "Configure or make install" and other commands, at most, write a makefile management source file dependencies, but the software developers are different, He must take into account the portability of the software, he developed the software can not just on his own PC run it? Different platforms may have different hardware architectures, which leads to makefile, and in order to solve this problem, developers often use tools such as autoconf to generate corresponding configure scripts, and configure scripts are used to block the corresponding platform differences So that the Makefile file is generated correctly, and make then compiles the link work based on Configure's labor results (Makefile).
As for "Install or clean or uninstall", but also corresponds to the makefile file in the different rules, about makefile details, friends can consult the relevant documents themselves.

An example
Here is the process of installing the TAR tool on my PC's source code as a concrete example of these steps:

[Email protected] ~]# head-n 1/etc/issuecentos release 5.4 (Final) [[email protected] ~]# Uname-srlinux 2.6.18-164.el5[  [Email protected] ~]# gcc--versiongcc (gcc) 4.1.2 20080704 (Red Hat 4.1.2-46) Copyright (C) 2006 free software Foundation, Inc.

This is my system information.

[[email protected] tools]# pwd/root/tools[[email protected] tools]#  Lstar-1.23.tar.bz2[[email protected] tools]# tar jxvf tar-1.23.tar.bz2 ... [[email protected] tools]# lstar-1.23  tar-1.23.tar.bz2[[email protected]  tools]# cd tar-1.23[[email protected] tar-1.23]# lsabout-nls      build-aux   configure     gnu       makefile.am  po       srcacinclude.m4  changelog     configure.ac  INSTALL  Makefile.in  README    testsaclocal.m4    ChangeLog.1  COPYING        lib      Make.rules   rmt       thanksauthors       config.h.in  doc            M4       news         scripts   todo

Unzip the original package and discover that it includes the Configure script and the Readme file.

[Email protected] tar-1.23]# mkdir-v ~/tarmkdir: Created directory "/root/tar" [[email protected] tar-1.23]#./configure--prefix=/r Oot/tar ... [[email protected] tar-1.23]# echo $?

Set up the Software installation directory, and configure, check the Configure return results for 0 to run successfully.

[[Email protected] tar-1.23]# ls -fabout-nls     changelog.1      configure.ac  m4/           po/       tests/acinclude.m4  config.h         COPYING       Makefile     README    THANKSaclocal.m4    config.h.in      doc/          makefile.am  rmt/       TODOAUTHORS       config.log       gnu/          makefile.in   scripts/build-aux/    config.status*  INSTALL        make.rules   src/changelog     configure*      lib/           NEWS          Stamp-h1

Copy Code

You can see that the makefile file has been successfully established.

[email protected] tar-1.23]# less Makefile | grep Install: | | {echo "Error:files left after uninstall:"; Install:install-recursiveuninstall:uninstall-recursive

Install and uninstall markings are present in the established makefile

[[email protected] tar-1.23] #make ... [[email protected] tar-1.23] #echo &?

0

Make successful

[[email protected] tar-1.23] #make install ... [Email protected] tar-1.23]# ls/root/tarbin libexec sbin share[[email protected] tar]# cd/root/tar/bin[[email Protec Ted] bin]# Lstar[[email protected] bin]#./tar--help ... [[email protected] tar-1.23] #echo &?

0

Installation and simple test success


This article is from the "Mr_computer" blog, make sure to keep this source http://caochun.blog.51cto.com/4497308/1564168

linux-Source Software Installation method

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.