從源碼編譯 Vim 8


為什么自己的博客不能出現在百度首頁呢,看來確實得好好研究 SEO 了。

作為 Vim 重度依賴者, 是時候記錄下 *nix 系統從源碼編譯 Vim 的過程了.

CentOS

一路遇到了不少坑, 遇到奇奇怪怪的錯誤, 沒有依依記錄, 直接寫下成功的編譯過程.
(系統版本 CentOS 7.3 x64)

  1. 系統用U盤進行安裝的, 自帶了個 python2.7. 首先安裝必要包(可能不全)

    yum install mercurial ncurses-devel ruby ruby-devel lua lua-devel luajit python-devel python34 python34-devel
    
  2. 克隆 Vim 的倉庫

    git clone https://github.com/vim/vim.git
    

    或者自己 clone 到碼雲的倉庫:

    git clone https://gitee.com/shinemic/vim.git
    
  3. 開始各種配置:

    ./configure --with-features=huge \
                --enable-rubyinterp=yes \
                --enable-luainterp=yes \
                --enable-perlinterp=yes \
                --enable-pythoninterp=yes \
                --enable-python3interp=yes \
                --with-python-config-dir=/usr/lib64/python2.7/config \
                --with-python3-config-dir=/usr/lib64/python3.4/config-3.4m \
                --enable-fontset=yes \
                --enable-cscope=yes \
                --enable-multibyte \
                --disable-gui \
                --enable-fail-if-missing \
                --prefix=/usr/local \
                --with-compiledby='Professional operations'
    

    對其中的參數稍作解釋:

    • --enable-fail-if-missing 表示一旦出現配置錯誤, 則報錯並停下來,
      這時候可以看到什么方面沒有配置好, 方便排錯, 否則還要往回翻看一大串的信息
    • ...interp=yes 表示加入某某支持
    • 在加入對 python 的支持中, 出現了各種問題, 最終發現是沒有安裝 python-dev
      以及 python34-devel. 同樣 lua 也要安裝 lua-devel.
      另外 ...-config-dir 也是很重要的, 默認情況下 Vim 是找不到他們的配置路徑的
  4. 編譯.

    make
    make install
    
  5. 開耍. vim --version

    VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug  3 2017 06:43:08)
    Included patches: 1-844
    Compiled by root@Dorawk-workstation
    Huge version without GUI.  Features included (+) or not (-):
    +acl             +file_in_path    +mouse_sgr       +tag_old_static
    +arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
    +autocmd         +float           +mouse_urxvt     -tcl
    -balloon_eval    +folding         +mouse_xterm     +termguicolors
    -browse          -footer          +multi_byte      -terminal
    ++builtin_terms  +fork()          +multi_lang      +terminfo
    +byte_offset     +gettext         -mzscheme        +termresponse
    +channel         -hangul_input    +netbeans_intg   +textobjects
    +cindent         +iconv           +num64           +timers
    -clientserver    +insert_expand   +packages        +title
    -clipboard       +job             +path_extra      -toolbar
    +cmdline_compl   +jumplist        +perl            +user_commands
    +cmdline_hist    +keymap          +persistent_undo +vertsplit
    +cmdline_info    +lambda          +postscript      +virtualedit
    +comments        +langmap         +printer         +visual
    +conceal         +libcall         +profile         +visualextra
    +cryptv          +linebreak       +python/dyn      +viminfo
    +cscope          +lispindent      +python3/dyn     +vreplace
    +cursorbind      +listcmds        +quickfix        +wildignore
    +cursorshape     +localmap        +reltime         +wildmenu
    +dialog_con      +lua             +rightleft       +windows
    +diff            +menu            +ruby            +writebackup
    +digraphs        +mksession       +scrollbind      -X11
    -dnd             +modify_fname    +signs           -xfontset
    -ebcdic          +mouse           +smartindent     -xim
    +emacs_tags      -mouseshape      +startuptime     -xpm
    +eval            +mouse_dec       +statusline      -xsmp
    +ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
    +extra_search    -mouse_jsbterm   +syntax          -xterm_save
    +farsi           +mouse_netterm   +tag_binary
       system vimrc file: "$VIM/vimrc"
         user vimrc file: "$HOME/.vimrc"
     2nd user vimrc file: "~/.vim/vimrc"
          user exrc file: "$HOME/.exrc"
           defaults file: "$VIMRUNTIME/defaults.vim"
      fall-back for $VIM: "/usr/share/vim"
    Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H
    -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
    Linking: gcc   -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic
    -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE   -L/usr/local/lib -Wl,
    --as-needed -o vim        -lm -ltinfo -lnsl  -lselinux   -ldl  -L/usr/lib -llua
    -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector
    -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread
    -lc    -lruby -lpthread -lrt -ldl -lcrypt -lm
    

Ubuntu

系統版本 Ubuntu 16.04+.

sudo apt-get install libncurses5-dev libgnome2-dev \
                     libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
                     libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
                     python3-dev ruby-dev lua5.1 lua5.1-dev liblua5.1-dev libperl-dev git
./configure --with-features=huge \
            --enable-luainterp=yes \
            --enable-rubyinterp=yes \
            --enable-perlinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \
            --enable-python3interp=yes \
            --with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu \
            --enable-fontset=yes \
            --enable-cscope=yes \
            --enable-multibyte \
            --enable-fail-if-missing \
            --enable-gui=gtk2 \
            --prefix=/usr/local \
            --with-compiledby='Professional operations'

MSYS2

首先編譯 lua:

curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz
tar zxf lua-5.3.4.tar.gz
cd lua-5.3.4
pacman -S ncurses-devel libcrypt-devel gettext-devel
make mingw && cd .. && make install

配置:

./configure --with-features=huge \
            --enable-luainterp=yes \
            --enable-perlinterp=yes \
            --enable-pythoninterp=yes \
            --enable-python3interp=yes \
            --with-lua-prefix=/usr/local \
            --enable-fontset=yes \
            --enable-cscope=yes \
            --enable-multibyte \
            --disable-gui \
            --enable-fail-if-missing \
            --prefix=/usr/local \
            --with-compiledby='Professional operations'

其它

插件管理器

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

個人 vimrc:

注意事項

  • CentOS 機器上若安裝其它版本的 Python, 可能導致各種與 Python 相關的問題
    (比如 Vim: Caught deadly signal ABRT),
    在編譯的時候靈活取舍 pythonpython3 選項即可
  • 若不能 configure, 執行 make distclean


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM