現在Vim的最新版本是v7.3,而CentOS最新只能更新到v7.2,所以想自己編譯安裝一下試試,順便安裝gvim,不過最后gvim還是安裝失敗了。不知道為什么,先記錄一下,后面再摸索摸索吧:
1、下載vim源代碼
vim的官方網站是:www.vmunix.com/vim
可以用這個鏈接下載源碼包:ftp://ftp.jp.vim.org/pub/vim/unix/vim-7.0.tar.bz2
2、解壓
將 /usr/src/vim-7.3.tar.bz2 文件解壓縮在 /usr/local 底下
可以用這個鏈接下載源碼包:ftp://ftp.jp.vim.org/pub/vim/unix/vim-7.0.tar.bz2
2、解壓
將 /usr/src/vim-7.3.tar.bz2 文件解壓縮在 /usr/local 底下
cd /usr/local tar -xvf /usr/src/vim-7.3.tar.bz2
3、配置
./configure --prefix=/usr/local/vim73 --with-x --enable-gui=gtk2 --with-features=big --disable-selinux --enable-multibyte
- 這里如果沒有“--disable selinux”configure的時候會報錯:
os_unix.c:45:30: 錯誤:selinux/selinux.h:沒有那個文件或目錄
os_unix.c: In function ‘mch_copy_sec’:
os_unix.c:2667: 警告:隱式聲明函數 ‘is_selinux_enabled’
os_unix.c:2671: 錯誤:‘security_context_t’ 未聲明 (在此函數內第一次使用)
os_unix.c:2671: 錯誤:(即使在一個函數內多次出現,每個未聲明的標識符在其
os_unix.c:2671: 錯誤:所在的函數內只報告一次。)
os_unix.c:2671: 錯誤:expected ‘;’ before ‘from_context’
os_unix.c:2672: 錯誤:expected ‘;’ before ‘to_context’
os_unix.c:2674: 警告:隱式聲明函數 ‘getfilecon’
os_unix.c:2674: 錯誤:‘from_context’ 未聲明 (在此函數內第一次使用)
os_unix.c:2687: 錯誤:‘to_context’ 未聲明 (在此函數內第一次使用)
os_unix.c:2692: 警告:隱式聲明函數 ‘freecon’
os_unix.c:2697: 警告:隱式聲明函數 ‘setfilecon’
make[2]: *** [objects/os_unix.o] 錯誤 1
make[2]: Leaving directory `/opt/bzip2/vim73/src'
make[1]: *** [myself] 錯誤 2
make[1]: Leaving directory `/opt/bzip2/vim73/src'
make: *** [first] 錯誤 2
os_unix.c: In function ‘mch_copy_sec’:
os_unix.c:2667: 警告:隱式聲明函數 ‘is_selinux_enabled’
os_unix.c:2671: 錯誤:‘security_context_t’ 未聲明 (在此函數內第一次使用)
os_unix.c:2671: 錯誤:(即使在一個函數內多次出現,每個未聲明的標識符在其
os_unix.c:2671: 錯誤:所在的函數內只報告一次。)
os_unix.c:2671: 錯誤:expected ‘;’ before ‘from_context’
os_unix.c:2672: 錯誤:expected ‘;’ before ‘to_context’
os_unix.c:2674: 警告:隱式聲明函數 ‘getfilecon’
os_unix.c:2674: 錯誤:‘from_context’ 未聲明 (在此函數內第一次使用)
os_unix.c:2687: 錯誤:‘to_context’ 未聲明 (在此函數內第一次使用)
os_unix.c:2692: 警告:隱式聲明函數 ‘freecon’
os_unix.c:2697: 警告:隱式聲明函數 ‘setfilecon’
make[2]: *** [objects/os_unix.o] 錯誤 1
make[2]: Leaving directory `/opt/bzip2/vim73/src'
make[1]: *** [myself] 錯誤 2
make[1]: Leaving directory `/opt/bzip2/vim73/src'
make: *** [first] 錯誤 2
- 如果沒有安裝ncurses這個庫,configure的時候還是會報錯:
checking for tgetent in -lncurses... no
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib.
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib.
安裝ncurses
yum install ncurses-devel
安裝ncurses后重新configure:
/configure --prefix=/usr/local/vim73 --with-x --enable-gui=gtk2 --with-features=big --disable-selinux --enable-multibyte
4、make/make install
接下來執行: make && make install 。現在你的Vim7.3就在 /usr/local/了 O(∩_∩)O~
5、建立鏈接
mv /usr/bin/vim /usr/bin/vim_backup # 先將原來的備份 ln -s /usr/local/vim73/bin/vim /usr/bin/vim # 再將vim 7.3鏈接過來
6、運行
當運行vim的時候,顯示已經升級到最新版的7.3了
但是在執行gvim命令的時候,提示:
[root@localhost ~]# gvim
bash: /usr/bin/gvim: 沒有那個文件或目錄
是不是沒有建立鏈接,
ln -s /usr/local/vim73/bin/gvim /usr/bin/gvim 還是不行
到/usr/local/vim73/bin/一看,根本沒有gvim,真是不明白為什么。我的配置過程中明明加了--enable-gui=gtk2,過程中似乎沒有什么提示啊。敬請高手指點!
最后還是裝了老的版本:
yum install vim-X11