1.在LLVM官网上下载适合自己版本的压缩包:
http://releases.llvm.org/download.html#8.0.0
我的是:http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
2.在~目录下新建ycm_temp文件夹,将tar包解压缩于此处
cd
mkdir ycm_temp
3.在~目录下再新建ycm_build文件夹,进入此文件夹,执行:
cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=~/ycm_temp/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04/ . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py ~/.ycm_extra_conf.py
vim ~/.ycm_extra_conf.py
在flags里加上:
'-isystem',
'/usr/include',
'-isystem',
'/usr/include/c++/(自己对应的版本)',
'-isystem',
'/usr/include',
'/usr/include/x86_64-linux-gnu/c++',
同时还要注释掉:
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
vim ~/.vimrc
添加:
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
7.然而在我用vim打开一个文件时,下面报了错:
The ycmd server SHUT DOWN (restart with ':Ycm..._55905_stderr_hefghvlb.log' to check the logs.
然后我查了一下,进行了如下操作:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer
就好了.
参考博客:
https://blog.csdn.net/yue7603835/article/details/53140891
http://howiefh.github.io/2015/05/22/vim-install-youcompleteme-plugin/
https://www.cnblogs.com/lysuns/p/4222707.html
https://blog.csdn.net/gis_101/article/details/78769347