答:進入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