centos8 安裝 YcM


  • 環境: centos8

[root@localhost ~]# uname -a
Linux localhost.localdomain 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

centos8 自帶 vim8.0

[root@localhost ~]# vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 11 2019 19:08:24)
Included patches: 1-1763
Modified by <bugzilla@redhat.com>

centos8 自帶 python 3.6.8

[root@localhost ~]# python3 --version
Python 3.6.8

 

centos8 yum安裝 cmake

[root@localhost ~]#yum install cmake 

[root@localhost ~]# cmake --version cmake version 3.11.4 CMake suite maintained and supported by Kitware (kitware.com/cmake).

yum 安裝依賴包

 yum 下載依賴包

yum -y install libXt-devel gtk2-devel        

yum -y install python-devel ruby ruby-devel perl perl-devel perl-ExtUtils-Embed

yum -y install ncurses-devel  zlib-devel bzip2-devel openssl-devel  sqlite-devel readline-devel tk-devel

yum -y install gcc gcc-c++ make automake

yum -y install ctags

yum -y  install yum-utils

yum-builddep -y llvm clang

yum -y install epel-release

yum install python-pip

pip install distribute
  • 安裝 vbundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

在根目錄下創建 .vimrc文件

[root@localhost ~]# vim ./.vimrc 

# 在 .vimrc 中添加如下

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" Plugins
Plugin 'Valloric/YouCompleteMe'

call vundle#end()
filetype plugin indent on

 

 打開 vim

[root@localhost ~]# vim 

:pluginList  # 可以看到插件列表
:PluginInstall # 安裝成功后,會顯示DONE!

 

 

 

下載 YouCompleteMe

這里我采用git下載的方式安裝,沒有通過在Plugin列表里安裝

git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

安裝YouCompleteMe

[root@localhost ~]# cd .vim/bundle/YouCompleteMe/
[root@localhost YouCompleteMe]# ./install.sh --clang-complete

會提示錯誤

[root@localhost YouCompleteMe]#  ./install.sh --clang-complete
WARNING: this script is deprecated. Use the install.py script instead.
ERROR: folder waitress in /root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party is empty; you probably forgot to run:
        git submodule update --init --recursive

根據提示,輸入 

git submodule update --init --recursive

等待git去下載其他相關文件

安裝完成

再次安裝 ./install.sh --clang-complete

[root@localhost YouCompleteMe]# ./install.sh --clang-complete

提示錯誤:

[root@localhost YouCompleteMe]# ./install.sh --clang-complete
WARNING: this script is deprecated. Use the install.py script instead.
Searching Python 3.6 libraries...
ERROR: Python headers are missing in /usr/include/python3.6m.

於是我們安裝  python36-devel

[root@localhost YouCompleteMe]#  yum -y install python36-devel
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
。。。。。。。。。。。。。。
Installed:
  python36-devel-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64     platform-python-devel-3.6.8-15.1.el8.x86_64    
  python-rpm-macros-3-37.el8.noarch                             python3-rpm-generators-5-4.el8.noarch          

Complete!

再次安裝./install.sh --clang-complete  有提示錯誤: 注意標顏色的那一行

[root@localhost YouCompleteMe]# ./install.sh --clang-complete
WARNING: this script is deprecated. Use the install.py script instead.
Searching Python 3.6 libraries...
Found Python library: /usr/lib64/libpython3.6m.so
Found Python headers folder: /usr/include/python3.6m
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib64/libpython3.6m.so (found suitable version "3.6.8", minimum required is "3.5")
-- Downloading libclang 9.0.0 from https://dl.bintray.com/ycm-core/libclang/libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2
CMake Error at ycm/CMakeLists.txt:107 (file):
  file DOWNLOAD HASH mismatch

    for file: [/root/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/../clang_archives/libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2]
      expected hash: [4b1986be100f0067848d3c15c2a66cc3bb91c7e648ccf89ddd5e77a208b72d26]
        actual hash: [e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
             status: [6;"Couldn't resolve host name"]



CMake Error at ycm/CMakeLists.txt:123 (message):
  Cannot find path to libclang in prebuilt binaries


-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build_id6fvbwa/CMakeFiles/CMakeOutput.log".
ERROR: the build failed.

NOTE: it is *highly* unlikely that this is a bug but rather
that this is a problem with the configuration of your system
or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the
issue tracker, including the entire output of this script
and the invocation line used to run it.

報錯: 注意這一行:Downloading libclang 9.0.0 from https://dl.bintray.com/ycm-core/libclang/libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2

下載文件失敗

我們提取地址:https://dl.bintray.com/ycm-core/libclang/libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2 放到瀏覽器 url 里面,自動下載   libclang 9.0.0

下載 內容放在 /root/.vim/bundle/YouCompleteMe/third_party/ycmd/clang_archives   目錄下下面 並解壓

[root@localhost clang_archives]# ls
libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2  libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2.bak
[root@localhost clang_archives]# tar xvf libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2 
LICENSE.TXT
lib/libclang.so
lib/libclang.so.9
[root@localhost clang_archives]# ls
lib                                              libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2.bak
libclang-9.0.0-x86_64-unknown-linux-gnu.tar.bz2  LICENSE.TXT

再次安裝:./install.sh --clang-complete     編譯完成 最后又出錯了

[root@localhost YouCompleteMe]# ./install.sh --clang-complete
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Word.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Result.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Utils.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o
[100%] Linking CXX shared library /root/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
[100%] Built target ycm_core
CMake Error: The source directory "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
ERROR: the build failed.

 實際上,到這里已經可以了,可能有點小瑕疵 心煩

 

我參考了下面的,感激不盡:

https://www.cnblogs.com/liongong/p/9671947.html

https://www.cnblogs.com/zhyantao/p/10424884.html

https://michael728.github.io/2018/12/02/tools-vim-plugin-config/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM