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 <[email protected]>

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

会提示错误

扫描二维码关注公众号,回复: 9506909 查看本文章
[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/

猜你喜欢

转载自www.cnblogs.com/gupan1311/p/12389090.html