天天看點

源碼安裝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