In addition to installing, updating, and uninstalling software using the Linux package management mechanism, installing software from the source code is also very common. Open source software provides the source code package, developers can easily install the SDK through the source code. Software Installation from the source code generally follows three steps: software configuration, software compilation, and installation.
If you want to hear the voice broadcast from Niu every day and want to learn more IT technologies or skills that are not available in schools and books, please pay attention to the public account.:Xiniubook2008. Or addWeibo: I am the master of my books, Participate in the activity, get a book for free.
7.3.1 Software Configuration
Because the software depends on the underlying library resources of the system, the main function of software configuration is to check the current system software and hardware environment and determine whether the current system meets the software resources required by the current software. The configuration command is generally as follows:
[Root @ CentOSvim73] #./congure-prefix =/usr/local/vim73
The -- prefix specifies the installation path. The compiled binary files and other files will be installed here.
Different software configure scripts provide a variety of options. After the execution is complete, the system generates a compilation rule file Makefile Based on the execution options and system configurations. To view the parameters supported by the current software configuration, you can use the./configure -- help Command.
7.3.2 compile software
After the compilation options are configured, the system has generated the Makefile required for the compilation software, and then compiled using these makefiles. Compile the software and execute the make command:
[Root @ CentOSvim73] # make
After the make command is executed, make will generate the target file, such as a binary program, based on the Makefile file.
7.3.3 Software Installation
After compilation, run the make install command to install the software:
[Root @ CentOSvim73] # make install
Generally, the installed software can be used after the installation is complete. If no installation path is specified, the general software will be installed in the/usr/local directory to create the corresponding folder, some software binaries are installed in the/usr/bin or/usr/local/bin/directory, and the corresponding header files are installed in/usr/include, the software help document is installed in the/usr/local/share directory.
If a directory is specified, the corresponding folder is created in the specified directory. After the software is installed, you must use an absolute PATH or configure the environment variables. That is, you must add the directory of the binary file of the software to the PATH of the system environment variable.
Vim is an excellent text editor. It provides a wide range of vi editor functions and is widely used by developers. Emacs and other editing software of the same type are available. The example 7-6 demonstrates how to install the software through source code. The example also contains the Problems and Solutions encountered during software installation.
(1) first check whether there is Vim in the system. If yes, uninstall it first to avoid confusion.
[Example 7-6]
# Check whether Vim software exists in the system
[Root @ CentOS ~] # Vim -- version | head
VIM-Vi IMproved 7.3 (2010 Aug 15, compiled Apr 112013 03:32:13)
# View the vim File Location
[Root @ CentOS ~] # Which vim
/Usr/bin/vim
# View the software package of the current software
[Root @ CentOS ~] # Rpm-qf/usr/bin/vim
Vim-enhanced-7.2.411-1.8.el6.x86_64
# Uninstall the currently installed software package
[Root @ CentOS ~] # Rpm e vim-enhanced-7.2.411-1.8.el6.x86_64
# Check whether the file still exists
[Root @ CentOS ~] # Ls-lhtr/usr/bin/vim
Ls: cannot access/usr/bin/vim: No such file ordirectory
(2) After the above steps, confirm that there is no Vim in the system, and install Vim below. The latest version of Vim can be downloaded at http://www.vim.org.
[Example 7-6] continued
[Root @ CentOS ~ ] # Cd/data/soft
# Upload the source code package
[Root @ CentOSsoft] # rz-bye
Rz waiting to receive.
Start zmodem transmission. Press Ctrl + C to cancel.
Transferring vim-7.3.tar.bz2...
100% 8867 KB 4433 KB/s 00:00:02 0 error
# Decompress the source code package
[Root @ CentOSsoft] # tar xvf vim-7.3.tar.bz2
Vim73/
Vim73/Makefile
Vim73/src/Makefile
Vim73/configure
Vim73/src/configure
Vim73/src/auto/configure
# Some results are omitted
Vim73/src/configure. in
Vim73/src/
[Root @ CentOSsoft] # cd vim73
# View the file list. Some results are omitted.
[Root @ CentOSvim73] # ls
Configure README_unix.txt Makefile src
# Step 2: configure the software
[Root @ CentOSvim73] #./configure
Configure: creating cache auto/config. cache
Checking whether make sets $ (MAKE)... yes
Checking for gcc... gcc
# Some results are omitted
Checking for tgetent ()... configure: error: NOTFOUND!
Youneed to install a terminal library; for example ncurses.
Orspecify the name of the library with -- with-tlib.
# Some libraries do not exist. Find and install them. The rpm package is used for installation.
[Root @ CentOSvim73] # cd-
/Cdrom/Packages
[Root @ CentOSPackages] # ls-l ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
-R --. 2 root 657212 Jul 3 2011ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
# Install dependent packages
[Root @ CentOSPackages] # rpm-ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
Warning: ncurses-devel-5.7-3.20090208.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ######################################## ### [100%]
1: ncurses-devel ##################################### ###### [100%]
[Root @ CentOSPackages] # cd-
/Data/soft/vim73
# Configure the software again
[Root @ CentOSvim73] #./configure -- prefix =/usr/local/vim73
Configure: creating cache auto/config. cache
Checking whether make sets $ (MAKE)... yes
# Some results are omitted
Checking whether we need-D_FORTIFY_SOURCE = 1... yes
Configure: creating auto/config. status
Config. status: creating auto/config. mk
Config. status: creating auto/config. h
# Step 2: Compile the software
[Root @ CentOSvim73] # make
If there are problems, cd to the src directory andrun make there
Cd src & make first
Make [1]: Entering directory '/data/soft/vim73/src'
Mkdir objects
CC = "gcc-Iproto-DHAVE_CONFIG_H" srcdir =. sh./osdef. sh
Gcc-c-I.-Iproto-DHAVE_CONFIG_H-g-O2-D_FORTIFY_SOURCE = 1-o objects/buffer. o buffer. c
# Some results are omitted
(3) After completing the preceding steps, the Vim software has been compiled and the installation of Vim continues.
[Example 7-6] continued
# Step 2: Install Vim
[Root @ CentOSvim73] # make install
Startingmake in the src directory.
If thereare problems, cd to the src directory and run make there
Cd src & make install
Make [1]: Entering directory '/data/soft/vim73/src'
If test-f/usr/local/vim73/bin/vim; then \
Mv-f/usr/local/vim73/bin/vim/usr/local/vim73/bin/vim. rm ;\
Rm-f/usr/local/vim73/bin/vim. rm ;\
Fi
Cp vim/usr/local/vim73/bin
# Some results are omitted
[Root @ CentOSvim73] # vim -- version
VIM-Vi IMproved 7.3 (2010 Aug 15, compiled Apr 112013 03:32:13)
(4) now the Vim software has been installed. If you want to use it, use the absolute PATH or set the environment variable PATH.
[Example 7-6] continued
# Using vim to find that the command does not exist
[Root @ CentOSvim73] # vim-version
-Bash:/usr/local/bin/vim: No such file or directory
[Root @ CentOSvim73] # cd/usr/local/vim73/
[Root @ CentOSvim73] # ls
Bin share
[Root @ CentOSvim73] # export PATH =/usr/local/vim73/bin/: $ PATH :.
[Root @ CentOSvim73] # vim -- version
VIM-Vi IMproved 7.3 (2010 Aug 15, compiled Apr 112013 03:32:13)
The preceding example demonstrates how to install the specified software through the source code. The installation process includes software configuration, software compilation, and software installation. If the installation directory is not specified during software installation, you need to use the absolute PATH or add the directory where the binary file of the software is located to the PATH of the system variable, so that you can still use the installed software without using the absolute path.
If you like, you can purchase the "super easy Linux System Management entry book".CurrentlyLinuxChina is holding an interactive forum. You can get a book by writing a book review!