Sir zach

专注于算法,AI, Android以及音视频领域 欢迎关注我的最新博客: zachliu.cn

导航

Ubuntu14.04 32位安装YouCompleteMe

Posted on 2014-07-30 21:09  SirZach  阅读(564)  评论(0编辑  收藏  举报

  YouCompleteMe是一个相当好用的代码补全插件,由于更新系统重装了一下,记录一下过程。

  项目主页: https://github.com/Valloric/YouCompleteMe , 感觉很多地方写的不是太清楚,需要仔细阅读。

  1、首先要安装vim

   sudo apt-get install vim  安装后vim版本已经到7.4了,达到要求(Vim 7.3.584+)。

  2、安装vundle, 这是一个vim插件管理工具。

  https://github.com/gmarik/Vundle.vim#about

   安装后进入vim, 执行 :BundleInstall 即可完成安装。 

  3、如果需要c语言的语法检查支持,则需要安装生成makefile需要libclang.so(3.2+). 系统里我是搜了半天都没搜到,官网也只提供了x86_64位版本的二进制包,所以只好用源码编译。

  参考http://clang.llvm.org/get_started.html 即可。

 主要过程如下;

If you would like to check out and build Clang, the current procedure is as follows:

  1. Get the required tools.
  2. Checkout LLVM:
    • Change directory to where you want the llvm directory placed.
    • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
  3. Checkout Clang:
    • cd llvm/tools
    • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
    • cd ../..
  4. Checkout extra Clang Tools: (optional)
    • cd llvm/tools/clang/tools
    • svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
    • cd ../../../..
  5. Checkout Compiler-RT:
    • cd llvm/projects
    • svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
    • cd ../..
  6. Build LLVM and Clang:
    • mkdir build (for building without polluting the source dir)
    • cd build
    • ../llvm/configure --enable-optimized     这里如果不加优化选项,无法编译成功,提示ld 内存不足,很诡异。
    • make

  4、编译成功之后则会生成一个libclang.so, 时间挺长的,接着生成Makefile:

    mkdir ycm_build

    cd ycm_build 

    cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/your/path/to/libclang.so . ~/.vim/bundle/YouCompleteMe/cpp/

  5、开始编译

    make ycm_core