本文记录了我第一次安装VIM的那些坑,第一次安装还把centos搞坏了,第二次重装系统才装成功。
我记录了每一步操作,可以尽可能的还原当时的情况。过程只是成功的步骤,在后面会把其他失败的尝试写出来,以供参考。
我安装了以下插件
- Plugin ‘gmarik/Vundle.vim’ //插件管理,一键安装插件
- Plugin ‘bling/vim-airline’ //炫酷状态栏
- Plugin ‘scrooloose/nerdtree’ //文件目录树状图
- Plugin ‘kien/ctrlp.vim’ //文件搜索
- Plugin ‘taglist.vim’ //程序结构显示
- Plugin ‘Valloric/YouCompleteMe’ //语法自动补全
- Plugin ‘winmanager’ //窗口管理
预览图
我首先在虚拟机把centos6.5最小版本安装好,这部分不做介绍。 接下来每个软件都是必须要安装的,否则缺少依赖。另外,我是全程使用root用户登录,不存在权限问题。
打开vi ~/.bash_profile在后面添加:.
,能让系统查找当前目录的可执行文件。
- yum install ntp
- ntpdate time.nist.gov
由于虚拟机的时间错误,太超前,导致后面出现很多警告。
这些依赖都是后面要用到的,比如zlib-devel 如果不安装,之后安装,会导致后面python需要重新编译,非常麻烦。
yum install -y gcc gcc-c++ gdb ctags ncurses-devel libevent-devel git automake xz zlib-devel cmake libxml2 libxslt libxslt-devel kernel-devel wget openssl openssl-devel
我这里顺序有问题,应该直接安装新版gcc,glibc,之后再安装其他依赖。
参考http://blog.csdn.net/officercat/article/details/39520227
- wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.17.tar.xz
- xz -d glibc-2.17.tar.xz
- tar -xvf glibc-2.17.tar
- cd glibc-2.17
- mkdir build
- cd build
- ../configure –prefix=/usr –disable-profile –enable-add-ons –with-headers=/usr/include –with-binutils=/usr/bin
- make && make install
输入strings /lib64/libc.so.6 | grep GLIBC发现已经更新
升级成功
参考http://blog.csdn.net/chenggong2dm/article/details/9100591
http://www.cnblogs.com/balaamwe/p/3480430.html
- wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
- xz -d Python-2.7.10.tar.xz
- tar -xvf Python-2.7.10.tar
- cd Python-2.7.10
- ./configure –enable-shared
- make && make install
- /usr/local/bin/python2.7 -V
此时报错
参考 http://blog.csdn.net/huzhenwei/article/details/7339548
在/etc/ld.so.conf中加入新行/usr/local/lib 保存后,
运行
- /sbin/ldconfig
- /sbin/ldconfig –v
- mv /usr/bin/python /usr/bin/python.bak
- ln -s /usr/local/bin/python2.7 /usr/bin/python
- vi /usr/bin/yum
在打开的文件里的头一行,也就是指定python环境的那行代码,修改成:
#!/usr/bin/python2.6
成功
- wget https://bootstrap.pypa.io/ez_setup.py -O - | python
安装成功
- wget –no-check-certificate https://github.com/pypa/pip/archive/7.1.0.tar.gz
- tar zvxf 7.1.0.tar.gz #解压文件
- cd pip-7.1.0
- python setup.py install
安装成功,继续安装依赖
- pip install requests
- pip install lxml
- pip install cssselect
- pip install flake8
成功
参考 https://github.com/VundleVim/Vundle.vim
- git clone https://github.com/gmarik/Vundle.vim.git
- ~/.vim/bundle/Vundle.vim
我的.vimrc中Vundle的配置暂时如下,完整配置见最后:
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" My Plugins here: Plugin 'bling/vim-airline' Plugin 'scrooloose/nerdtree' Plugin 'kien/ctrlp.vim' Plugin 'taglist.vim' Plugin 'Valloric/YouCompleteMe' Plugin 'winmanager' let g:winManagerWindowLayout="NERDTree|TagList" let g:NERDTree_title="[NERDTree]" function! NERDTree_Start() exec 'NERDTree' endfunction function! NERDTree_IsValid() return 1 endfunction " All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
在vim里执行,先把这些插件下载下来
- :PluginInstall
下面你不要运行,这步是安装YouCompleteMe,这里会安装失败,直接下一步更新GCC。
到 ~/.vim/bundle/YouCompleteMe 下运行
- ./install.sh –clang-completer
我还安装了VIM主题
主题来自https://github.com/flazz/vim-colorschemes/tree/master/colors
YouCompleteMe 仍然出错
日志提示version `GLIBCXX_3.4.14’ not found
- strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
显示系统GLIBC版本
参考http://tieba.baidu.com/p/2812712726
- wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2
- tar -jxvf gcc-4.8.5.tar.bz2
- cd gcc-4.8.5
- ./contrib/download_prerequisites
- cd ..
- mkdir gcc-build-4.8.5
- cd gcc-build-4.8.5
- ../gcc-4.8.5/configure –enable-checking=release –enable-languages=c,c++ –disable-multilib
- make -j7
- make install
GCC编译需要很长时间,我用了40分钟左右。
- gcc -v
显示更新成功
下面更新libstdc++.so.6
参考http://www.linuxidc.com/Linux/2015-01/112057.htm
我的文件在
/gcc-build-4.8.5/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.18
- cp libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6.0.19
- ln -sf /usr/lib64/libstdc++.so.6.0.19 /usr/lib64/libstdc++.so.6
输入strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX查看成功
YouCompleteMe作者建议我们直接安装编译好的clang,自己编译会出现各种各样的错误!!!!实际上我确实出现了很多问题。
下面这些都不要执行,我这里尝试失败,直接看下面安装编译好的clang
* yum install svn
参考http://clang.llvm.org/get_started.html
http://www.linuxidc.com/Linux/2014-04/99719.htm
../llvm/configure –enable-optimized –enable-targets=host-only
make -j7
make install
make出错
重来,进入目录
cmake -G “Unix Makefiles” ../llvm
出错
cc1plus: 错误:无法识别的命令行选项“-std=c++11”
估计cmake需要在新的gcc下重新编译
参考http://520.be/zh-cn/2014/09/08/centos-6-5%E6%9B%B4%E6%96%B0cmake/
wget http://www.cmake.org/files/v3.2/cmake-3.2.3.tar.gz
等等
安装成功
重来,进入目录
cmake -G “Unix Makefiles” ../llvm
仍然错误
YCM项目主页 https://github.com/Valloric/YouCompleteMe
发现可下载编译好的clang,但是没有centos的!!!
http://llvm.org/releases/download.html 使用Clang for Fedora21 x86_64 Linux
- wget http://llvm.org/releases/3.5.1/clang+llvm-3.5.1-x86_64-fedora20.tar.xz
- xz -d clang+llvm-3.5.1-x86_64-fedora20.tar.xz
- tar xvf clang+llvm-3.5.1-x86_64-fedora20.tar
- cd clang+llvm-3.5.1-x86_64-fedora20
在/etc/profile这个档案最尾端添加以下两行代码:
PATH=/usr/local/cmake/bin:/usr/clang_3_3/bin:$PATH
export PATH
执行更新变量
- source /etc/profile
进入YCM目录
- mkdir build
- cd build
- cmake -G “Unix Makefiles” . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
- cmake -G “Unix Makefiles” -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
make ycm_support_libs
cp /usr/clang_3_5/lib/libclang.so ~/.vim/bundle/YouCompleteMe/python/libclang.so
进入YCM之后,安装YCM
- ./install.sh –clang-completer
根据http://www.bubuko.com/infodetail-446364.html
配置文件添加.ycm_extra_conf.py文件,非常重要
let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘
成功!!!!!
但是C语言标准库找不到!!!
参考http://blog.marchtea.com/archives/175
参考 http://blog.marchtea.com/archives/161
配置成功
在.ycm_extra_conf.py添加,让YCM找到库的位置,
每个人的位置不同
- echo | clang -std=c++11 -stdlib=libc++ -v -E -x c++ -
查看位置
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/clang_3_5/bin/../include/c++/v1',
'-isystem',
'/usr/clang_3_5/bin/../lib/clang/3.5.1/include',
C语言标准库提示出现
发现C语言系统函数不提示!!
参考http://tieba.baidu.com/p/3149197324#53359136436l
https://github.com/iSpeller/Profile/blob/master/vim/.vimrc
发现是YCM不自动提示,自动提示需要配置.vimrc如下
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/y cmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_semantic_triggers = {
\ 'c' : ['->', ' ', '.', ' ', '(', '[', '&'],
\ 'cpp,objcpp' : ['->', '.', ' ', '(', '[', '&', '::'],
\ 'perl' : ['->', '::', ' '],
\ 'php' : ['->', '::', '.'],
\ 'cs,java,javascript,d,vim,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':']
\ }
这样就可以自动提示了。
以下是.vimrc里的设置,winmanager对NERDTree的支持需要设置,否则报错,这里设置F2键切换窗口
Plugin 'winmanager'
let g:winManagerWindowLayout="NERDTree|TagList"
let g:NERDTree_title="[NERDTree]"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap <silent> <F2> :if IsWinManagerVisible() <BAR> WMToggle<CR> <BAR> else <BAR> WMToggle<CR>:q<CR> endif <CR><CR>
"这句话能够删除随winmanager自动打开的空窗口
- yum install man
出错
Cannot open the message catalog “man” for locale “zh_CN.UTF-8”
(NLSPATH=”/usr/share/locale/%l/LC_MESSAGES/%N”)
执行
yum install man-pages.noarch man-pages-overrides.noarch
还是不管
参考http://blog.csdn.net/lw1a2/article/details/6991529
将en下的man复制过来,先凑合用用:
- cp /usr/share/locale/en/LC_MESSAGES/man /usr/share/locale/zh/LC_MESSAGES/
成功
安装过程到此结束。下面贴出我的.vimrc设置。
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" My Plugins here:"
Plugin 'bling/vim-airline'
"let g:airline_powerline_fonts = 1"
set laststatus=2
set t_Co=256
Plugin 'scrooloose/nerdtree'
let mapleader=","
nmap <silent> <leader>ne :NERDTree<CR>
nmap <silent> <leader>nc :NERDTreeClose<CR>
"map <silent> <F3> :NERDTreeToggle<CR>"
Plugin 'kien/ctrlp.vim'
"Plugin 'altercation/vim-colors-solarized'"
let g:ctrlp_custom_ignore = {
\ 'dir': 'vendor/bundle/*\|vendor/cache/*\|public\|spec',
\ 'file': '\v\.(exe|so|dll|swp|log|jpg|png|json)$',
\ }
syntax enable
set background=dark
let g:solarized_termcolors=256
colorscheme flatcolor
Plugin 'taglist.vim'
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的"
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim"
"let Tlist_Use_Right_Window = 1" "在右侧窗口中显示taglist窗口"
"nmap <F4> :TlistToggle<cr>"
Plugin 'Valloric/YouCompleteMe'
Plugin 'rdnetto/YCM-Generator'
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
inoremap <c-o> <c-x><c-o>
let g:ycm_semantic_triggers = {
\ 'c' : ['->', ' ', '.', ' ', '(', '[', '&'],
\ 'cpp,objcpp' : ['->', '.', ' ', '(', '[', '&', '::'],
\ 'perl' : ['->', '::', ' '],
\ 'php' : ['->', '::', '.'],
\ 'cs,java,javascript,d,vim,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':']
\ }
Plugin 'winmanager'
let g:winManagerWindowLayout="NERDTree|TagList"
let g:NERDTree_title="[NERDTree]"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap <silent> <F2> :if IsWinManagerVisible() <BAR> WMToggle<CR> <BAR> else <BAR> WMToggle<CR>:q<CR> endif <CR><CR>
" All of your Plugins must be added before the following line"
call vundle#end() " required"
filetype plugin indent on " required"
set nu "show line number"
set ts=4 "tab length is 4"
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set list listchars=tab:→\ ,trail:·
set hlsearch incsearch smartcase ignorecase
autocmd BufNewFile,BufRead *.json set filetype=javascript
nmap mm :call ChangeMouse()<cr>
function ChangeMouse()
if &mouse == "a"
set mouse-=a
else
let &mouse = "a"
endif
endfunction
set nocompatible
set autoindent
set backspace=indent,eol,start
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936
set fileencoding=utf-8
我这里还安装了TMUX,能够终端多窗口
右下角是htop
很奇怪
inoremap <c-m> <c-x><c-o>
会导致回车键触发提示。。。
换成ctrl+o
inoremap <c-o> <c-x><c-o>
echo $TERM 发现putty结果为xterm
set t_Co=256
- yum install automake
- yum install libevent-devel ncurses-devel
原因是使用的libevent的版本太低造成的,要求libevent>= 2.0.10-stable
- wget –no-check-certificate https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
按照https://blog.linuxeye.com/323.html
成功安装
vim需要python支持,需要重新编译
教程http://blog.csdn.net/forlong401/article/details/42356241
编译失败
http://stackoverflow.com/questions/3373914/compiling-vim-with-python-support
Yea! I figured it out, so I’m writing up a quick how-to in case others run into the same issue:
1. I didn't notice an important message in the configure output:
checking if compile and link flags for Python are sane… no: PYTHON DISABLED
2. The log file had more info located in src/auto/config.log:
/usr/bin/ld: skipping incompatible /2.5/lib/python2.5/config//libpython2.5.a when searching for -lpython2.5/usr/bin/ld: cannot find -lpython2.5
3. I found an old thread that said you can override the gcc call by setting:
export vi_cv_path_python_plibs=”-L//2.5/lib/python2.5/config/ …”
excluding the -lpython2.5
Now it compiles.
决定安装python2.7
参考http://blog.csdn.net/chenggong2dm/article/details/9100591
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
yum install xz
xz -d Python-2.7.10.tar.xz
tar -xvf *
cd Python-2.7.10
./configure
make
make install
/usr/local/bin/python2.7 -V
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python2.7 /usr/bin/python
等等。。
重新安装vim
编译安装
make distclean
cd vim74/src
./configure –enable-multibyte –with-features=huge –enable-pythoninterp=yes –with-python-config-dir=/usr/lib64/python2.7/config
make
make install
安装成功
打开vim提示 cm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need
to compile YCM before using it. Read the docs!
参考
http://www.cnblogs.com/junnyfeng/p/3633697.html
执行 ./install.sh –clang-completer
提示安装CMAKE
yum install cmake
执行 ./install.sh –clang-completer
编译失败 估计跟两个python共存有关系
再次编译失败
can not be used when making a shared object; recompile with -fPIC
参考https://github.com/Valloric/YouCompleteMe/issues/131
重新编译python2.7
./configure –enable-shared
make && make install
出错libpython2.7.so.1.0 cannot open
http://blog.csdn.net/huzhenwei/article/details/7339548
在/etc/ld.so.conf中加入新行/usr/local/lib 保存后,运行 /sbin/ldconfig /sbin/ldconfig –v
成功
重新安装youcompleteme插件
http://www.cnblogs.com/junnyfeng/p/3633697.html
到 .vim/bundle/YouCompleteMe 下跑
./install.sh –clang-completer
编译成功,但是打开vim出错
error 132_SetUpPython in Freebsd
https://github.com/Valloric/YouCompleteMe/issues/976
重新下载安装插件YouCompleteMe
到 .vim/bundle/YouCompleteMe 下跑
./install.sh –clang-completer
在下载什么东西。。。。
编译成功
打开vim出错
Error detected while processing function youcompleteme#Enable
准备跑run_tests.sh出错缺少flake8
需要先安装pip
wget –no-check-certificate https://github.com/pypa/pip/archive/7.1.0.tar.gz
tar zvxf 1.5.5.tar.gz #解压文件
cd pip-1.5.5/
python setup.py install
出错 No module named setuptools
需要安装setuptools
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
出错AttributeError: ‘NoneType’ object has no attribute ‘decompressobj’
需要重新编译python
找到http://www.cnblogs.com/balaamwe/p/3480430.html
一次安装所有依赖
先yum install zlib-devel
然后编译
tar -xvf *
cd Python-2.7.10
./configure –enable-shared
make && make install
然后再安装setuptools
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
安装成功
重新安装pip
python setup.py install
安装成功
重新安装flake8
pip install flake8
成功
发现YCM错误是No module named ‘requests.packages.urllib3’
根据http://stackoverflow.com/questions/27440060/how-to-fix-importerror-no-module-named-packages-urllib3
pip install requests
pip install lxml
安装失败
make sure the development packages of libxml2 and libxslt are installed
参考http://www.udpwork.com/item/11846.html
yum install libxml2
yum install libxslt
重新pip install lxml 仍然失败
参考http://blog.csdn.net/azhao_dn/article/details/7501432
yum install libxslt-devel
重试pip install lxml
成功
pip install cssselect
成功
打开vim尝试,成功加载YCM
出错The ycmd server SHUT DOWN
参考https://github.com/Valloric/YouCompleteMe/issues/914 打开debug
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = ‘debug’
输入:YcmDebugInfo显示错误日志位置
日志显示libc.so.6: version `GLIBC_2.14’ not found
参考http://blog.csdn.net/cpplang/article/details/8462768
wget http://mirror.bjtu.edu.cn/gnu/libc/glibc-2.14.tar.xz
xz -d glibc-2.14.tar.xz
tar -xvf glibc-2.14.tar
进入
yum出现错误
参考http://www.360doc.com/content/13/1109/11/6496277_327860778.shtml
链接libc.so.6错误,各种命令不能用。。。
参考http://www.shangxueba.com/jingyan/2477411.html
ldconfig -l -v /lib64/libc-2.12.so
问题解决
ln -s -f /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6
YCM提示libc.so.6: version `GLIBC_2.15’ not found
下载新版Glibc2.7
参考
http://www.cppblog.com/windcsn/archive/2012/08/08/186663.html
wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.7.tar.gz
tar -xvf glibc-2.7.tar.gz
cd glibc-2.7
mkdir build
cd build
../configure –prefix=/opt/glibc-2.7
出错
configure: error:
* These critical programs are missing or too old: as ld
参考http://blog.csdn.net/testcs_dn/article/details/45437903
更新binutils
wget http://distfiles.macports.org/binutils/binutils-2.25.tar.bz2
新版本还是不行
手动在configure屏蔽as 和ls版本的检查
make && make install
make失败!!!!
换成glibc-2.5也不行,还是as 和ls版本问题as 和ls版本问题问题
降级binutils-2.19
wget http://distfiles.macports.org/binutils/binutils-2.19.tar.bz2
tar jxvf binutils-2.19.tar.bz2
进入
./configure
make && make install
进入glibc-2.7/bulid
../configure –prefix=/opt/glibc-2.7
成功
make && make install
失败
make[2]: * [/root/vim7-4/glibc-2.7/build/nscd/nscd] 错误 1
make[2]: Leaving directory /root/vim7-4/glibc-2.7/nscd'
/root/vim7-4/glibc-2.7’
make[1]: *** [nscd/others] 错误 2
make[1]: Leaving directory
make: * [all] 错误 2
明天再试
原来2.7是老版本。。。比2.12版本还小。。。
wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.20.tar.xz
xz -d glibc-2.20.tar.xz
tar -xvf glibc-2.20.tar
../configure –prefix=/opt/glibc-2.20
出错,更新binutils
解压进入
./configure
出错
checking for C compiler default output file name…
参考
yum install gcc gcc-c++ kernel-devel
不管
使用rpm安装
wget ftp://rpmfind.net/linux/fedora/linux/development/rawhide/x86_64/os/Packages/b/binutils-2.25-12.fc23.x86_64.rpm
rpm -ivh binutils-2.25-12.fc23.x86_64.rpm
需要GLIBC_2.14
从rpm更新glibc
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-2.17-78.el7.x86_64.rpm
需要wget http://mirror.centos.org/centos/7/os/x86_64/Packages/glibc-common-2.17-78.el7.x86_64.rpm
查看版本rpm -qi glibc
更新失败,有依赖。。。
放弃这个虚拟机。。。。。还有其他问题