問題描述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
複製**
cd /usr/local/src
wget
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
複製**
如果有其他的問題,可以參考公眾幹號:浪子程式設計走四方 centOS7公升級git版本到2 23 0
centos7.5自帶git,7.x版本自帶git 1.8.3.1。先進行git版本檢測 git version一 安裝依賴包 yum y install zlib devel curl devel openssl devel perl cpio expat devel gettext devel ...
centos7公升級pip版本
但是pip沒有設定的話,其實使用的指向還是python2的 那麼我們要公升級pip的話首先要把pip指向python 進入usr bin目錄 cd usr bin 檢視pip字首的檔案 ll pip 刪除pip檔案 rm pip 重新設定pip檔案 ln s usr local python3 bi...
centos7公升級GLIBC版本
之前在乙個centos7虛擬機器上執行目標程式的時候,發現自己的編譯環境比目標執行機的centos7系統的glibc版本要高,執行的時候報錯,說找不到glibc 2.18。於是在該centos7執行 strings libc.so.6 grep glibc 2.1 命令,發現最glibc的最高版本是...