Centos7 升级vim7到vim8的两种方法 | Eddie'Blog
Centos7 升级vim7到vim8的两种方法

Centos7 升级vim7到vim8的两种方法

eddie 1,794 2020-04-22

版本

系统版本

 CentOS Linux release 7.7.1908 (Core)

rpm 安装

优缺点

  • 优点
    • 易于升级,易于卸载
  • 缺点
    • 不能指定python版本开启

运行指令

rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
yum -y remove vim-minimal vim-common vim-enhanced sudo
yum -y --enablerepo=gf-plus install vim-enhanced sudo

编译安装

优缺点

  • 优点
    • 扩展性强
  • 缺点
    • 安装难度对于初学者,不易上手

卸载自带旧版 vim7.x

yum remove vim*

下载源码

# 推荐下载网址,Github上永世下载不了
http://www.linuxfromscratch.org/blfs/view/stable-systemd/postlfs/vim.html

# 下载 vim-8.2.0190.tar.gz
wget http://anduin.linuxfromscratch.org/BLFS/vim/vim-8.2.0190.tar.gz

查看Vim是否支持python

# 减号不支持 加号则是支持
[root@m1 temp]# vim --version | grep python
+cmdline_info      +libcall           -python            +visual
+comments          +linebreak         -python3           +visualextra

下载必须依赖

yum install -y ruby ruby-devel lua lua-devel luajit luajit-devel ctags git python python-devel python3 python3-devel tcl-devel perl perl-devel perl-ExtUtils*

安装步骤

1、下载
链接:https://pan.baidu.com/s/1Lxg8A-RMLyP7Mjwo8CX0XA 
提取码:wqoc 

2、解压
tar -zxf vim-8.2.0190.tar.gz
cd vim-8.2.0190/
cd src/

3、通过configure配置安装路径,并支持python2.7、python3
./configure --with-features=huge \
        --enable-multibyte \
        --enable-rubyinterp=yes \
        --enable-python3interp=yes \
        --with-python-config-dir=/usr/local/python3/lib/python3.8/config-3.8-x86_64-linux-gnu \
	--with-python-config-dir=/usr/lib64/python2.7/config \
        --enable-perlinterp=yes \
        --enable-luainterp=yes \
        --enable-gui=gtk2 \
        --enable-cscope \
        --prefix=/usr/local/vim

4、编译安装
make && make install

5、验证
/usr/local/vim/bin/vim -version

6、创建软连接
ln -s /usr/local/vim/bin/vim  /usr/bin/vim  

问题汇总

错误1

# 例1:
objects/main.o: In function `getout':
/root/temp/vim-8.2.0190/src/main.c:1689: undefined reference to `perl_end'
objects/buffer.o: In function `free_buffer':
/root/temp/vim-8.2.0190/src/buffer.c:901: undefined reference to `perl_buf_free'
objects/evalfunc.o: In function `f_perleval':
/root/temp/vim-8.2.0190/src/evalfunc.c:5063: undefined reference to `do_perleval'
objects/ex_docmd.o:(.rodata+0x46e8): undefined reference to `ex_perl'
objects/ex_docmd.o:(.rodata+0x4708): undefined reference to `ex_perldo'
objects/window.o: In function `win_free':
/root/temp/vim-8.2.0190/src/window.c:4899: undefined reference to `perl_win_free'
collect2: error: ld returned 1 exit status
link.sh: Linking failed
make: *** [vim] Error 1

出现上述问题解决办法:
1. 查看依赖是否安装
2. 创建 xsubpp 文件夹 cd /usr/share/perl5/ExtUtils && mkdir xsubpp
3. 根据makefile或者第一个报错的指引,找到生成if_perl.c的命令,手动生成即可:

/bin/perl -e 'unless ( $] >= 5.005 ) { for (qw(na defgv errgv)) { print "#define PL_$_ $_\n" }}' > auto/if_perl.c
/bin/perl /usr/share/perl5/ExtUtils/xsubpp -prototypes -typemap \
    /usr/share/perl5/ExtUtils/typemap if_perl.xs >> auto/if_perl.c

4. 回到Vim的 $PATH/src
make clean
make && make install

# Linux