git install the latest version under linux

1, the first step to uninstall the original git.

yum remove git

 

2, the installation of dependencies

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc yum install gcc perl-ExtUtils-MakeMaker

 

3, install git

将压缩包解压到/usr/local/src目录
tar -C /usr/local/src -vxf git-2.7.3.tar.xz cd git-2.7.3 // 编译 make prefix=/usr/local/git all // 安装 make prefix=/usr/local/git install // 写入到环境变量中(方法一) echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile && source /etc/profile // 写入到环境变量中(方法二) export PATH=$PATH:/usr/local/bin/git
//不想重启系统,使用source命令立即生效
source /etc/profile // 查看是否已经安装成功 git --version

The normal process is carried out in accordance with the above processes can be installed, summarizes some of the few problems encountered during the installation process below.
1, the make prefix = / usr / local / git All the following tips when compiling error

 LINK git-credential-store
libgit.a(utf8.o): In function `reencode_string_iconv': /usr/src/git-2.8.3/utf8.c:463: undefined reference to `libiconv' libgit.a(utf8.o): In function `reencode_string_len': /usr/src/git-2.8.3/utf8.c:502: undefined reference to `libiconv_open' /usr/src/git-2.8.3/utf8.c:521: undefined reference to `libiconv_close' /usr/src/git-2.8.3/utf8.c:515: undefined reference to `libiconv_open' collect2: ld returned 1 exit status make: *** [git-credential-store] Error 1 

The main problem is the lack of libiconv library system caused. According to the link provided above, you can download libiconv.

cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14 配置 ./configure --prefix=/usr/local/libiconv 编译 make 安装 make install 建立软连接 ln -s /usr/local/lib/libiconv.so /usr/lib ln -s /usr/local/lib/libiconv.so.2 /usr/lib 

This time also libiconv library installation has been completed, the following entry in our git installation directory, installed in accordance with the following manner

make configure
./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv 编译 make 安装 make install 加入环境变量 export PATH=$PATH:/usr/local/bin/git 检测版本号 git --version 

2, when you install libiconv encounter ./stdio.h:1010:1: error: 'gets' undeclared error here (not in a function), and the following operations can be solved.

进入错误文件路径
cd libiconv-1.14/srclib
编辑文件stdio.in.h找到698行的样子,内容是_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 将这一行注释掉(注意注释一定要用/**/来进行注释),替换为下面的内容 #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); #endif

作者:鹏飞q
链接:https://www.imooc.com/article/275738
来源:慕课网
本文原创发布于慕课网 ,转载请注明出处,谢谢合作

Guess you like

Origin www.cnblogs.com/zwsblogs/p/11577429.html