linux-1:源码安装

        在linux系统中,源码的安装一般有3个步骤组成:配置(configure)、源码(make)、安装(make install),具体的安装方法一般作者都会给出文档,这里主要讨论配置(configure)。Configure是一个可执行脚本,它有很多选项,使用命令./configure –help输出详细的选项列表,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
-bash-3.00# ./configure --help
Usage: configure [options][ host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print `checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX [/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]

        其中–prefix选项就是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share,比较分散。为了便于集中管理某个软件的各种文件,可以配置–prefix,如:./configure –prefix=/usr/local

        可以把所有资源文件放在/usr/local的路径中,就不会分散了。用了—prefix选项的另一个好处是卸载软件或移植软件。当某个安装的软件不再需要时,只须简单地删除该安装目录,就可以把软件卸载得干干净净;移植软件只需拷贝整个目录到另外一个机器即可(相同的操作系统)。当然要卸载程序,也可以在原来的make目录下用一次make uninstall,但前提是make文件指定过uninstall。

        尤其是在服务器上,普通用户没有sudo权限,执行./configure会提示:./configure: Permission denied。可以使用–prefix将按照的配置路径放在自己的目录下,因为像/usr/local/lib此类的目录普通用户是没有写的权限的,会造成安装失败。失败的还要一种可能的原因是当前源码中的configure文件没有可执行权限,也会导致“Permission denied”。可以使用“ll”命令查看文件的权限,然后使用chmod命令对该文件加上可执行的权限“chmod +x ./configure”。

参考:

http://www.maybe520.net/blog/1945/

本文标题:linux-1:源码安装

文章作者:goingcoder

发布时间:2018年01月18日 - 17:01

最后更新:2018年01月23日 - 19:01

原始链接:https://goingcoder.github.io/2018/01/18/linux/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------本文结束感谢您的阅读-------------