答:进入YouCompleteMe的安装目录安装一些必要的依赖
比如:笔者将YouCompleteMe安装到了~/.vim/bundle目录下,那么执行以下操作:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --system-libclang
(如果出现安装失败,请尝试添加选项--no-regex,也就是./install.py --clang-completer --system-libclang --no-regex)
补充:
1. Q: 出现以下错误:
ERROR: Unable to find executable 'cmake'. CMake is required to build ycmd
A: 请安装cmake
ubuntu下的安装方法: sudo apt-get install cmake -y
2. Q: 出现以下错误:
CMake Error at ycm/CMakeLists.txt:330 (message):
Using Clang completer, but no libclang found. Try setting
EXTERNAL_LIBCLANG_PATH or revise your configuration
A: 请安装libclang开发库
ubuntu下的安装方法: sudo apt-get install libclang-dev -y
3. Q: 出现以下错误:
fatal error: Python.h: No such file or directory
compilation terminated.
ycm/CMakeFiles/ycm_core.dir/build.make:182: recipe for target 'ycm/CMakeFiles/ycm_core.dir/ClangCompleter/ClangHelpers.cpp.o' failed
A: 安装python开发库
ubuntu下的安装方法: sudo apt-get install libpython-dev -y
4. Q: 出现以下错误:
No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++
A:
4.1 将配置文件复制到对应的目录中
mkdir ~/.vim/bundle/YouCompleteMe/cpp/ycm -p
cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/bundle/YouCompleteMe/cpp/ycm
4.2 配置.vimrc
echo "let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'" >> ~/.vimrc