Problem Description
The default git installation version of the centos7 system is 1.8, but the git version is found to be too low during the project construction, so I use source code compilation to upgrade. At the same time, this article is also applicable to installing new git, I believe everyone has a certain understanding of git Now, some steps in the article process will not be explained in detail.
Operating environment
centos7.0
Software preparation
git version, libiconv
Installation process
1、 The first step is to uninstall the original git.
yum remove git
2、 Installation related dependencies
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install gcc perl-ExtUtils-MakeMaker
3、 Install git
Unzip the compressed package to/usr/local/src directory
tar -C /usr/local/src -vxf git-2.7.3.tar.xz
cd git-2.7.3//Compile
make prefix=/usr/local/git all
//installation
make prefix=/usr/local/git install
//Write to environment variable (Method 1)
echo "export PATH=$PATH:/usr/local/git/bin">>/etc/profile && source /etc/profile
//Write to environment variable(Method Two)export PATH=$PATH:/usr/local/bin/git
//Check whether the installation is successful
git --version
problem solved
The normal process is to install according to the above process. The following summarizes some problems encountered during the installation process. 1. The following error is prompted when compiling with 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
This problem is mainly caused by the lack of libiconv library in the system. According to the link provided above, 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
Configuration
. /configure --prefix=/usr/local/libiconv
Compile
make
installation
make install
Establish soft connection
ln -s /usr/local/lib/libiconv.so /usr/lib
ln -s /usr/local/lib/libiconv.so.2/usr/lib
At this time, the libiconv library has been installed, enter our git installation directory below, and install it in the following way
make configure
. /configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
Compile
make
installation
make install
Add environment variables
export PATH=$PATH:/usr/local/bin/git
Check the version number
git --version
2、 When installing libiconv, you will encounter the error message ./stdio.h:1010:1: error:'gets' undeclared here (not in a function), you can solve it by following the steps below.
Enter the wrong file path
cd libiconv-1.14/srclib
Edit file stdio.in.h finds line 698, the content is_GL_WARN_ON_USE(gets,"gets is a security hole - use fgets instead");Comment out this line(Note that the annotation must be used/**/To comment), Replace with the following
# ifdefined(__GLIBC__)&&!defined(__UCLIBC__)&&!__GLIBC_PREREQ(2,16)_GL_WARN_ON_USE(gets,"gets is a security hole - use fgets instead");
# endif
Recommended Posts