| This post was last edited by milk tea DSK In Linux, many software is released through the source code package. for end users, configuration and compilation are cumbersome compared with binary software packages, however, it is much more portable. For different architectures, software developers only need to publish the same source code package. Different end users can run the program correctly after compilation, this is also very in line with the C language design philosophy, a write, everywhere, and common Binary packages, such as RPM and Deb, software developers must customize special software packages for each specific platform. The extension of the RPM file can be used to get a glimpse, such as PPC, iSCSI, i386, and so on. There are no too many statements here, in fact, the source code installation software is far less complex than many friends think. I will make some detailed statements here as much as possible. If there are any mistakes, you are welcome to make a brick! Installation steps:
- $ Tar zxvf xxxx.tar.gz (or tar jxvf xxxx.tar.bz2)
- $ CD xxxx
- $./Configure
- $ Make
- # Make install
- $ Make clean
Used to clear temporary files after installation
- # Make uninstall
Used to uninstall software
Decompress: The tools used for files ending with xxxx.tar.gz or Taobao are tar and Bzip2. The reason for this is that tar can only Package Multiple files but does not have the compression function, in contrast, GZ and bz2 can only compress a single file. In this way, the common source code package is to package different source files through tar first, then it is released after being compressed by gunzip or Bzip2. Of course, the two steps can be implemented through one command:
- $ Tar zcvf xxxx.tar.gz xxxx (or tar jcvf xxxx.tar.bz2 XXXX)
The command for decompression is as follows:
- $ Tar zxvf xxxx.tar.gz
- $ Tar jxvf xxxx.tar.bz2
./Configure: After decompression, the installation is officially started. (before configure is started, use the patch tool to patch the source code if necessary.) First, jump to the decompressed directory of the source code. As we all know, before starting configure, you should carefully read the README or install files in the source code directory. Many precautions for installation are listed here. Configure is actually a script file, type ". /configure ", shell will run the configure script in the current directory. It must be noted that the compilation has not been completed in the entire configure process. Configure is only used to prepare for compilation, it mainly performs dependency checks on your current work platform, such as whether the compiler is installed and whether the connector exists. If there are no errors in the detection process, you are lucky, the configure script will generate another MAKEFILE file used for the next compilation link in the current directory. Of course, configure supports its rich command line parameters. You can type ". /configre -- Help "to obtain specific information. The most common ones are:
- $./Configure -- prefix =/opt/xxx
It is used to set the installation directory of the software.
Make: If the configure process is completed correctly, the corresponding MAKEFILE file will be generated in the source code directory. In short, the MAKEFILE file includes a set of file dependencies and compilation links, in fact, the real compilation link is not done by make. Make is just a common tool. Generally, make will call the appropriate compiler according to the rules in makefile to compile all source code that is dependent on the current software, generate all relevant target files, and then use the linker to generate the final executable program:
- $ Make
Make install: When the above two steps are completed correctly, it indicates that the compilation link process has completely ended. The last thing to do is to install the executable program to the correct position. In this step, normal users may not have permission to operate related directories. It is a good option to temporarily switch to root. "Install" is only a label in the MAKEFILE file, "make install" indicates that the make tool executes all the operations under the "Install" label in the MAKEFILE file, if "-- prefix =/opt/XXX" is not used in configure stage to specify the installation directory of the application, the application will be installed to/usr/local/bin by default, if/usr/local/bin already exists in your path, the installation has basically ended:
- # Make install
Make clean: Make uninstall: These two steps are only subsequent operations for installation. Note that "clean" and "Uninstall" are two numbers in the MAKEFILE file. The MAKEFILE file must be retained when you perform these two steps, "Make clean" is used to clear some temporary files during the compilation and connection process. "Make Uninstall" is used to uninstall related applications. Similar to make install, make uninstall also needs to be switched to root for execution, however, the "Uninstall" label is omitted in many makefiles. You can find out the correct makefile.
Why? Here I try to explain the reasons for the above steps. From the perspective of C language, the following parts are essential for a program from the source code to the correct generation of relevant executable files: the source file, compiler, assembler, connector, and dependent library are already known through the above steps. There is only one (make) step to really execute the compilation link operation ), what are the reasons for the existence of other steps? One thing is certain. I use C language to write some self-Entertaining mini programs on my computer, and I have not used commands such as "configure or make install, at most, write a makefile to manage the dependency between source files. However, different software developers must consider the portability of the software. The software he develops cannot only run on his own PC? Different platforms may have different hardware architectures, which leads to the portability of makefile. To solve this problem, developers usually use tools such as Autoconf to generate corresponding configure scripts, the configure script is used to block the corresponding platform differences, so as to correctly generate the MAKEFILE file, and then make completes the compilation link based on the configure's work result (makefile. As for "install or clean or Uninstall", it only corresponds to different rules in the MAKEFILE file. For more information about makefile, you can check related documents on your own. Example The following is the process of installing the tar tool from the source code on my PC. The permission is a specific example of the above steps:
- [Root @ localhost ~] # Head-N 1/etc/issue
- Centos release 5.4 (final)
- [Root @ localhost ~] # Uname-SR
- Linux 2.6.18-164. EL5
- [Root @ localhost ~] # GCC -- version
- GCC (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
- Copyright (c) 2006 Free Software Foundation, Inc.
This is my system information.
- [Root @ localhost tools] # pwd
- /Root/tools
- [Root @ localhost tools] # ls
- Tar-1.23.tar.bz2
- [Root @ localhost tools] # tar jxvf tar-1.23.tar.bz2
- ......
- [Root @ localhost tools] # ls
- Tar-1.23 tar-1.23.tar.bz2
- [Root @ localhost tools] # cd tar-1.23
- [Root @ localhost tar-1.23] # ls
- ABOUT-NLS build-Aux configure GNU makefile. am Po SRC
- Acinclude. M4 changelog Configure. AC install makefile. In readme tests
- Aclocal. M4 changelog.1 copying lib make. Rules RMT thanks
- Authors config. H. In Doc M4 News scripts todo
Decompress the original package and you will find that the configure script and readme file are included.
- [Root @ localhost tar-1.23] # mkdir-V ~ /Tar
- Mkdir: the directory "/root/tar" has been created"
- [Root @ localhost tar-1.23] #./configure -- prefix =/root/tar
- ......
- [Root @ localhost tar-1.23] # echo $?
- 0
Create a software installation directory, configure, and check the configure returned results. If it is 0, the operation is successful.
- [Root @ localhost tar-1.23] # ls-F
- ABOUT-NLS changelog.1 Configure. AC M4/po/tests/
- Acinclude. M4 config. h copying makefile readme thanks
- Aclocal. M4 config. H. in DOC/makefile. Am RMT/todo
- Authors config. Log GNU/makefile. In scripts/
- Build-Aux/config. Status * install make. Rules src/
- Changelog configure * lib/news stamp-h1
The MAKEFILE file has been successfully created.
- [Root @ localhost tar-1.23] # less makefile | grep install:
- | {Echo "error: files left after uninstall :";/
- Install: Install-recursive
- Uninstall: uninstall-recursive
The Install and uninstall labels exist in the created makefile.
- [Root @ localhost tar-1.23] # Make
- ......
- [Root @ localhost tar-1.23] # echo &?
- 0
Make successful
- [Root @ localhost tar-1.23] # make install
- ......
- [Root @ localhost tar-1.23] # ls/root/tar
- Bin libexec sbin share
- [Root @ localhost tar] # cd/root/tar/bin
- [Root @ localhost bin] # ls
- Tar
- [Root @ localhost bin] #./tar -- Help
- ......
- [Root @ localhost tar-1.23] # echo &?
- 0
Installation and simple test successful Then, let's say two more words: 1. understand exactly what you want to do and what you are doing. 2. Open-source famous saying "rtfm "!! Certificate --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
One supplement:
But I don't have./configure, and I can't use make. What's the matter, Lord? Is the Linux version incorrect? 846969004 published on
Two possibilities: 1. You downloaded a binary package that can be directly run instead of a source code package. 2. The configuration script is not configure
In both cases, you can refer to the README or install document to find out the details ,, Milk tea DSK published on
Second, I have seen that 7-zip does not have a configuration script, just make it. Published on
Repeat Readme! This post from: http://www.linuxdiyf.com/viewarticle.php? Id = 181890 |