vim插件YouCompleteMe的安装
vim开发中代码补全插件太弱(OmniCppComplete等),当看到YouCompleteMe的介绍,被其强大折服,决定改用YouCompleteMe。
安装YCM还有点周折,这里记录一下,供其他同学参考。
? ? ? ?
1 安装python(7.5)
./configure --prefix=/usr/local --enable-share CFLAGS=-fPICmake sudo make install
?
2 获取vim74并安装
编译安装vim74 可以参考?https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source,但里面有个关于perl的坑,后面说。
?
2.1下载 vim-7.4.tar.bz2 并安装
2.2 安装
./configure --with-features=huge --enable-rubyinterp --enable-pythoninterp --with-python-config-dir=/usr/local/bin/python2.7-config --enable-perlinterp --enable-gui=gnome --enable-cscope --enable-luainterp --prefix=/usr/local??
make VIMRUNTIMEDIR=/usr/local/share/vim/vim74
报错:
/usr/bin/perl -e 'unless ( $] >= 5.005 ) { for (qw(na defgv errgv)) { print "#define PL_$_ $_\n" }}' > auto/if_perl.c/usr/bin/perl /usr/share/perl5/ExtUtils/xsubpp -prototypes -typemap \ /usr/share/perl5/ExtUtils/typemap if_perl.xs >> auto/if_perl.cCan't open perl script "/usr/share/perl5/ExtUtils/xsubpp": 没有那个文件或目录make[1]: *** [auto/if_perl.c] 错误 2make[1]: Leaving directory `/home/fishermen/soft/program/vim74/src'make: *** [first] 错误 2
?
看来perl5 的ExtUtils缺dd,yum search查查:
yum search perl |grep ExtUtilsperl-ExtUtils-CBuilder.x86_64 : Compile and link C code for Perl modulesperl-ExtUtils-Embed.x86_64 : Utilities for embedding Perl in C/C++ applicationsperl-ExtUtils-MakeMaker-Coverage.noarch : Allows perl modules to check testperl-ExtUtils-ParseXS.x86_64 : Module and a script for converting Perl XS codeperl-ExtUtils-MakeMaker.x86_64 : Create a module Makefile
继续安装?perl-ExtUtils-Embed了,do:
sudo yum install perl-ExtUtils-Embed
重复执行2.2,应该可以成功了。
?
3 安装YCM
利用vundle安装YouCompleteMe,然后在YouCompleteMe执行:
?
Linking CXX shared library /home/fishermen/.vim/bundle/YouCompleteMe/python/ycm_core.so/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC/usr/local/lib/libpython2.7.a: could not read symbols: Bad valuecollect2: ld 返回 1make[3]: *** [/home/fishermen/.vim/bundle/YouCompleteMe/python/ycm_core.so] 错误 1make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] 错误 2make[1]: *** [ycm/CMakeFiles/ycm_core.dir/rule] 错误 2make: *** [ycm_core] 错误 2
?./configure CFLAGS=-fPIC CPPFLAGS=-fPIC --enable-shared
make; sudo make install;
好了YCM的install脚本通过,但是打开vim报clang的错,clang需安装。
?
4 安装CLang支持
参考
http://www.cnblogs.com/waterlin/archive/2011/07/14/2106056.htmlwo
由于我在虚拟机上安装,单cpu,编译了近5个小时
?
5 安装YCM_CORE
启动vim,可能会报ycm若干函数找不到,或者报"ycm_core too old",这个时候你需要安装ycm_core
方法:
cd ~mkdir ycm_buildcd ycm_buildcmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/usr/local ~/.vim/bundle/YouCompleteMe/cpp/make ycm_core
?到此,YCM安装完毕。
?
?