Compile YCM with a specific verion of python which is installed via pyenv

Install python with pyenv

To compile YCM, the python must be installed with --enable-shared option enabled. By default, pyenv doesn’t install python with this option on, so you need to tell pyenv that we need it:

1
CONFIGURE_OPTS="--enable-shared --with-system-expat --with-system-ffi" pyenv install 2.7.13

Install and Compile YCM

  1. Install YCM with vim-plug (or Vundle). I prefer to use vim-plug, simply add the following line to your vimrc file or init.vim file if you use neovim instead.

  2. Before compiling you have to install cmake.

  3. Here, we assume you installed YCM with vim-plug, the default YCM directory is in ~/.config/nvim/plugged/YouCompleteMe for neovim users.

    Create new folders for building YCM.

    1
    2
    3
    cd /tmp
    mkdir ycm_build
    mkdir -p ycm_temp/llvm_root_dir

    For support C-family languages autocomplete, you have to download the binary distribution of LLVM+Clang from llvm.org, and extract to ~/ycm_temp/llvm_root_dir

    Then run the following command in ~/ycm_build directory:

    1
    2
    3
    4
    5
    6
    7
    cmake -G "Unix Makefiles" -DUSE_PYTHON2=OFF \
    -DPYTHON_INCLUDE_DIR=~/.pyenv/versions/3.6.0/include/python3.6m \
    -DPYTHON_LIBRARY=~/.pyenv/versions/3.6.0/lib/libpython3.6m.so \
    -DPATH_TO_LLVM_ROOT=/usr . \
    ~/.config/nvim/plugged/YouCompleteMe/third_party/ycmd/cpp
    cmake --build . --target ycm_core --config Release

Note: Use the latest version of cmake to bypass potential errors or abnormalities.


¶ The end

Share Link: http://d0u9.win/posts/1936695139.html