出于某些原因,Ubuntu不能直接使用apt install命令安装应用程序,此时我们可以尝试直接下载源代码,然后手动配置,编译,安装。下面以常用的wget命令为例,说明从源代码安装。
**1.**从 gnu官网下载 Index of /gnu/wget下载wget的源代码,然后采用tar命令解压缩:
tar -zxvf wget-1.13.3.tar.gz
**2.**然后进入wget目录后,执行./configure命令,运行configure命令可能出现如下的错误:
configure: error: –with-ssl was given, but GNUTLS is not available.
此时可以执行命令./configure –with-ssl=openssl可能还会出现如下的错误提示:
configure: error: –with-ssl=openssl was given,but ssl is not avaliable.
该错误的可能原因虽然openssl安装,但对应的库没有安装,所以:
sudo apt-get install libssl-dev
再次运行./configure –with-ssl=openssl,正常。
**3.**步骤2的configure步骤顺利完成后,wget的根目录会出现Makefile文件,此时运行命令make编译,可能会出现如下的问题:
./stdio.h:1012: error: ‘gets’ undeclared here (not in a function)
到wget目录中,找到stdio.h文件,注意是wget目录(不是Ubuntu系统目录)下的stdio.h文件,然后注释掉stdio.h中的1012行,保存退出后,再次运行make命令,正常编译。
**4.**最后执行make install命令,将wget安装到系统目录中,注意可能需要用到管理员权限。如此,顺利编译安装完成。