CentOS6.6下安装git 2.6.2

本文介绍了在CentOS6.6上由于yum源中的git版本过旧,如何手动编译安装git 2.6.2。详细步骤包括更新系统、安装依赖、下载源码、解决编译时遇到的`libiconv`错误,以及最终的版本检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在CentOS5,由于yum源中没有git,所以需要预先安装一系列的依赖包。但在CentOS6的yum源中已经有git的版本了,可以直接使用yum源进行安装

sudo yum install git

但是yum源中安装的git版本是1.7.1,太老了,Github等需要的Git版本最低都不能低于1.7.2 。所以我们一般不用上面的方法。而是下载git源码,编译安装。

编译安装的步骤是:

(1)首先先更新系统

sudo yum update

(2)安装依赖的包

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

(3)下载git源码并解压缩

wget https://github.com/git/git/archive/v2.3.0.zip
unzip v2.3.0.zip
cd git-2.3.0

(4)编译安装

cd /usr/local/scr/git-2.8.3
make configure
./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
make
make install

注:安装git 2.x遇到undefined reference to `libiconv’

 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

解决如下:

        1、安装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

        2、创建一个软链接到/usr/lib

ln -s /usr/local/lib/libiconv.so /usr/lib
ln -s /usr/local/lib/libiconv.so.2 /usr/lib

        3、重新编译后,发现还是同样的错误undefined reference to `libiconv'

        相关资料参考:debian centos 等linux系统编译报错 undefined reference to `libiconv'-无忧答案网

# 将iconv.h重新命名
mv /usr/local/include/iconv.h /usr/local/include/iconv.h.bak

        4、然后回到git目录继续编译

cd /usr/local/scr/git-2.8.3
make configure
./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
make
make install

(5)检查一下版本号

git --version

参考文献

CentOS6.6下安装git 2.6.2_Roda的博客的博客-优快云博客

安装git 2.x遇到undefined reference to `libiconv‘_单林敏的博客-优快云博客

debian centos 等linux系统编译报错 undefined reference to `libiconv'-无忧答案网

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏天的一朵云

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值