ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Centos7升级Git版本

2019-10-22 10:05:46  阅读:261  来源: 互联网

标签:libiconv git 安装 make Centos7 Git usr 版本 local


centos 升级 Git 版本

问题描述

centos7 系统默认的 git 安装版本是 1.8,但是在项目构建中发现 git 版本过低,于是用源码编译的方式进行升级.同时该文章也适用于安装新的 git,相信大家对 git 都有一定的了解了,在文章过程中有的步骤也就不细细讲了.

操作环境

centos7.0

软件准备

git 版本,libiconv

安装流程

1、第一步卸载原有的 git。

yum remove git

2、安装相关依赖

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

3、安装 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
// 查看是否已经安装成功
git --version

问题解决

正常的流程就是按照上面的流程进行安装即可,下面总结一些在安装过程中遇到的几个问题.
1、make prefix=/usr/local/git all 进行编译的时候提示如下错误

 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

这个问题主要是系统缺少 libiconv 库导致的。根据上面提供的链接,下载 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

这时候还 libiconv 库已经安装完成,下面进入我们的 git 安装目录,按照下面的方式进行安装

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

2、在安装 libiconv 时会遇到./stdio.h:1010:1: error: 'gets' undeclared here (not in a function)的错误提示,进行下面的操作即可解决.

进入错误文件路径
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

本文由博客一文多发平台 OpenWrite 发布!

标签:libiconv,git,安装,make,Centos7,Git,usr,版本,local
来源: https://www.cnblogs.com/qqblog/p/11718123.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有