tar.gz源代码包安装_如何安装Tar.Gz或Tar.Bz2应用程序源代码?

本文详细介绍了如何在Linux系统中通过编译源代码来安装软件,包括使用wget下载源代码,使用tar提取,安装编译器和必备库,配置,用make编译以及使用make install进行安装等步骤。
摘要由CSDN通过智能技术生成
tar.gz源代码包安装

tar.gz源代码包安装

As a systems administrator I generally use package managers to install software. But in some situations I can not use package manager because provided software version is old or do not compatible. In this situations how can I install new software from source code by compiling.

作为系统管理员,我通常使用程序包管理器来安装软件。 但是在某些情况下,由于提供的软件版本过旧或不兼容,所以我无法使用软件包管理器。 在这种情况下,如何通过编译从源代码安装新软件。

Software source code can be get in different forms like compressed files like tar.bz2 , tar.gz or from repositories like git , svn etc. We will follow compressed way in this tutorial. To get more information about git read following tutorial.

软件源代码可以采用不同形式,如tar.bz2tar.gz等压缩文件,也可以从gitsvn等存储库中获取。我们将在本教程中按照压缩方式进行操作。 要获取有关git更多信息,请阅读以下教程。

Git Tutorial

Git教程

用wget下载源代码(Download Source Code with wget)

As stated previously we will get source code with the tool named wget .We will provide the url of the compressed source code. To get more information about wget look following tutorial.

如前所述,我们将使用名为wget的工具获取源代码。我们将提供压缩源代码的url。 要获取有关wget的更多信息,请查看以下教程。

Wget Command Tutorial With Examples For Linux

Wget命令教程和Linux示例

$ wget http://poftut.com/HelloWorld.tar.gz

用tar提取源代码 (Extract Source Code with tar)

Downloaded source code is compressed with tar.gz we will extract it with tar command like below.

下载的源代码已用tar.gz压缩,我们将使用tar命令将其提取,如下所示。

$ tar xvf HelloWorld.tar.gz

安装编译器和必需的库 (Install Compiler and Required Libraries)

Before compiling the source code we need to install related compilers and required libraries. More information about the required libraries can be found in the README file of the source code. In this step we will install gcc .

在编译源代码之前,我们需要安装相关的编译器和所需的库。 有关所需库的更多信息,可以在源代码的README文件中找到。 在这一步中,我们将安装gcc

$ sudo apt install gcc libgcc-5-dev

配置 (Configure)

Professional projects generally have configure script. configure script is used to te setup related files and folders before compiling. configure gets information about the current system and compiler with libraries and created Makefile .

专业项目通常具有configure脚本。 configure脚本用于在编译之前设置相关文件和文件夹。 configure通过库和创建的Makefile获取有关当前系统和编译器的信息。

$ ./configure

用make编译 (Compile with Make)

Now the most important part we will compile the source code. Make is very useful tool to compile the source code according to provided configuration. there is very complex compile configurations where they are easily handled by make command. We will just issue make like below. make should be run in source code root directory.

现在,最重要的部分我们将编译源代码。 Make是非常有用的工具,可以根据提供的配置来编译源代码。 有非常复杂的编译配置,可以通过make命令轻松地make配置。 我们将如下发出makemake应该在源代码的根目录中运行。

$ make

使编译更快 (Make Compile Faster)

Modern computers have more than single CPU core. If we do not provide any option the make command will compile the source code only using single core. We can use other cores during compile with -j option. This will use given number of cores. In this example we want to use 4 cores.

现代计算机具有多个CPU内核。 如果我们不提供任何选项, make命令将仅使用单核编译源代码。 在使用-j选项进行编译时,我们可以使用其他内核。 这将使用给定数量的内核。 在此示例中,我们要使用4个内核。

$ make -j 4

使用Make Install进行安装 (Install with Make Install)

Last step is installing the compiled binaries. We will use make install command. If the binaries will be copied to the directories those we do not have write right we should use with sudo command.

最后一步是安装编译的二进制文件。 我们将使用make install命令。 如果将二进制文件复制到我们没有写权限的目录,则应与sudo命令一起使用。

$ sudo make install
LEARN MORE  How To Uncompress and Untar Tar Gz File In Linux, Unix and BSD
了解更多信息如何在Linux,Unix和BSD中解压缩和解压缩Tar Gz文件

翻译自: https://www.poftut.com/install-tar-gz-tar-bz2-application-source-code/

tar.gz源代码包安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值