Linux software management - compile and install

EDITORIAL: bloggers is to join the training career after a battle-development experience "boars", a nickname taken from the animated film "The Lion King" in the "Peng Peng", always optimistic and positive attitude towards the surrounding thing. Technical route from my full-stack Java engineer all the way toward the development of big data, data mining, and now finally have small achievements, is willing to exchange 5012 we acquired the former, you want to learn the way of help. At the same time, the bloggers also want to try to create a complete technical library, any articles related to the technical point exceptions, error, precautions are listed at the end, welcome to provide material in various ways.

  • For any errors that appear in the article please critics pointed out, must be revised.
  • Have any questions you want to discuss and study can contact me: [email protected].
  • Publish the article because of the style column-specific, self-contained and inadequacies please correct me.

Linux software management - compile and install

Text Keywords: Linux, software management, configure, make, make install

First, prepare the environment

After a lot of software to download a source package, is not able to run directly, you need to compile the installation to generate an executable program. During compilation, you need to use yum install compilation tools.

1. Core Components

Must be installed is the gcc (GNU Compiler Collection) GNU compiler suite, which includes C, C ++, Objective-C, Fortran, Java, Ada, Go language front-end, but also includes the corresponding language library to fit almost overwhelming part-source software need to compile the environment.

yum install gcc

Here Insert Picture Description
After installation resolves the following issues:

2. Other components

During the actual installation of the software, due to the presence of dependent and may also call the relationship between software and software, such as: the introduction of a library at the time of writing source code, if our system is not related to the library, it will fail to compile this time we just install the appropriate error message can be based on the missing library, here are some commonly used libraries.

  • pcre
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

Here Insert Picture Description

yum install pcre-devel
  • zlib
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

Here Insert Picture Description

yum install zlib-devel
  • curl
src/main.c:18:23: 错误:curl/curl.h:没有那个文件或目录
src/main.c: 在函数‘main’中:
src/main.c:143: 警告:隐式声明函数‘curl_global_init’
src/main.c:143: 错误:‘CURL_GLOBAL_ALL’未声明(在此函数内第一次使用)
src/main.c:143: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
src/main.c:143: 错误:所在的函数内也只报告一次。)
src/main.c:397: 警告:隐式声明函数‘curl_global_cleanup’
make: *** [src/main.o] 错误 1

Here Insert Picture Description

yum install curl-devel
  • openssl
yum install openssl openssl-devel

Second, the installation process

1. Extract: tar -zvxf

Compile and install the first step and extract the installation is similar, you need to be decompressed, usually contains the following directories and content.

  • src目录:软件源码存放位置
  • LICENSE:许可及权限信息
  • README:帮助说明文档
  • configure:用于检测当前系统环境,用户自定义配置,以及生成makefile文件
  • Makefile:有可能直接存在,大多数情况下在执行configure后出现,用来指定编译的顺序及其他的复杂的功能操作

2. 配置:configure

编译安装的第一步就是执行configure脚本,会检查编译构建当前软件的所需环境,同时用户可以根据需要指定相关的配置。所有的选项以-‌-开头使用等号连接配置项与配置的值,如:-‌-prefix=/usr/local/。

  • -‌-prefix:指定编译安装时的目标路径,相当于自定义软件安装位置
  • -‌-bindir:指定二进制文件的安装位置
  • -‌-sbindir:指定超级二进制文件的安装位置
  • -‌-datadir:指定数据文件的安装位置
  • -‌-include:指定头文件的安装位置
  • -‌-infodir:指定info文档格式文件的安装位置
  • -‌-mandir:指定帮助文档的安装位置

在不指定安装位置时,将会安装到默认位置,通常分布在/usr/local中

3. 编译:make

在进行configure后,如果环境不存在问题,会生成对应的Makefile文件,用于执行make命令时调用。

在make过后,其实软件已经完成了安装,会在源码解压目录中生成构建完成的文件,如:Nginx软件make后会在obj文件夹中生成如下文件:
Here Insert Picture Description

4. 编译检查:make test/check

编译后可以使用make test或make check命令再次检查编译过程是否正确。

5. 编译安装:make install

执行最后一步:编译安装,根据configure阶段的配置,将已经生成的软件安装到指定的目录中去,可以对可执行文件定义软连接或者添加到环境变量,方便使用。

Published 32 original articles · won praise 213 · views 110 000 +

Guess you like

Origin blog.csdn.net/u012039040/article/details/104444056