cetnos下编译安装Git最新版

 费德  2016/06/08 23:57  839 次

在网上看到很多教程,首先是通过 git clone..,git都还没装,告诉我这个命令怎么用?
接下来,给大家一个最靠谱的安装教程。
1.进入/usr/local目录,下载git源码,并解压,得到git-master文件夹。

wget https://codeload.github.com/git/git/zip/master
unzip master
mv git-master git

2.进入git-master文件夹。

make prefix=/usr/local all

这里提示:

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

3.安装libiconv

cd /usr/local
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

这里如果提示:

./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)

输入以下命令

cd srclib/
sed -i -e '/gets is a security/d' ./stdio.in.h
cd ../
./configure -prefix=/usr/local/libiconv  &&  make  && make install

4.创建一个软链接到/usr/lib

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

5.返回git目录中继续编译

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

5.添加git软连接

 ln -s /usr/local/bin/git /usr/bin/

6.输入git --version
20160309225931.png

 作者:费德

少年费德的奇幻漂流

本博客如无特殊说明皆为原创,转载请注明来源:cetnos下编译安装Git最新版

添加新评论