安装git 2.x遇到undefined reference to `libiconv’
可能遇到报错:utf8.c:463: 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
解决如下:
安装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
创建一个软链接到/usr/lib
# ln -s /usr/local/lib/libiconv.so /usr/lib
# ln -s /usr/local/lib/libiconv.so.2 /usr/lib
然后回到git目录继续编译
# cd /usr/local/scr/git-2.8.3
# make configure
# ./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
# make
# make install
检查一下版本号
# git --version
自己的安装集成脚本
#!/bin/bash
cd git-2.24.1
yum remove git -y
make configure
./configure --prefix=/usr/local/ --with-iconv=/usr/local/libiconv
make -j10 && make install
ln -s /usr/local/bin/git /usr/bin/git
# 父bash也还是要自己source一遍
echo "父bash也还是要自己source一遍: source /etc/profile"
source /etc/profile
export | grep git
git --version
借鉴
https://www.cnblogs.com/wt645631686/p/8426506.html