源码安装vim8
背景
突然想要试用youcompleteme插件,但是yum安装的vim版本太低了,于是索性直接从源码编译vim8来使用,中间遇到了一些问题,记录一下以备后续查阅。
安装
下载源码
git clone https://github.com/vim/vim.git
编译、安装
cd vim/src
make
make install
默认安装在/usr/local/bin/vim,由于之前的vim还没卸载,于是直接使用绝对路径打开新的vim8,报错:
YouCompleteMe unavailable: requires Vim compiled with Python (3.6.0+) support
提示没有添加python3支持,于是重新编译
./configure --enable-python3interp=yes
make
make install
重新使用绝对路径打开vim,报错消失了,成功打开。
配置youcompleteme
参考官方文档:https://github.com/ycm-core/YouCompleteMe#full-installation-guide
执行python3 install.py --all
时报错:
Searching Python 3.7 libraries...
ERROR: found static Python library (/usr/local/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.a) but a dynamic one is required. You must use a Python compiled with the --enable-shared flag. If using pyenv, you need to run the command:
export PYTHON_CONFIGURE_OPTS="--enable-shared"
before installing a Python version.
原因:源码编译python3.7时没有添加--enable-shared选项,重新编译python3.7
make distclean
./configure --enable-shared --enable-optimizations
make
make install
再执行python3 install.py --all
成功。
安装好YCM之后,打开vim试一下,报错:
OSError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found
需要升级gcc版本,参考:https://blog.csdn.net/GUI1259802368/article/details/84934075
yum provides libstdc++.so.6
Loaded plugins: auto-update-debuginfo, fastestmirror
Loading mirror speeds from cached hostfile
libstdc++-4.8.5-4.el7.i686 : GNU Standard C++ Library
Repo : base
Matched from:
Provides : libstdc++.so.6
libstdc++-4.8.5-5.tl2.i686 : GNU Standard C++ Library
Repo : tlinux
Matched from:
Provides : libstdc++.so.6
libstdc++-4.8.5-39.tl2.i686 : GNU Standard C++ Library
Repo : tlinux
Matched from:
Provides : libstdc++.so.6
libstdc++-4.8.5-39.tl2.1.i686 : GNU Standard C++ Library
Repo : tlinux
Matched from:
Provides : libstdc++.so.6
libstdc++-4.8.5-39.tl2.1.i686 : GNU Standard C++ Library
Repo : @tlinux
Matched from:
Provides : libstdc++.so.6
安装最新版本:
yum install libstdc++-4.8.5-39.tl2.1.i686
新版本是安装在/usr/loca/lib64/目录下,需要将其拷贝到/usr/lib64目录下
cp /usr/local/lib64/libstdc++.so.6.0.28 /usr/lib64/
ln -sf /usr/lib64/libstdc++.so.6.0.28 /usr/lib64/
重新打开vim,报错消失,终于完成了。
参考:
https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source