Compile and install Vim7.4 + Vimgdb in Ubuntu 14.04
I. Preparations
1. Download Vim74 and vim-gdb for version 7.4:
(1)vim-7.4.tar.bz2
(2) vimgdb-for-7.4
2. Uninstall existing vim and related components
If vim has been installed in the Software Center, uninstall it.
Sudo apt-get remove vim-runtime gvim
You may also need to remove the following packages:
Sudo apt-get remove vim-tiny vim-common vim-gui-common
3. Install the dependent Environment
Manually compile and install Vim74. First install the required dependency library and header file for compilation.
Sudo apt-get build-dep vim
Compile again. If the dependency problem is not resolved, this prompt may appear:
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.
You can also manually install the following libraries to solve the dependencies. For the sake of security, it is best to execute them.
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 ruby-dev mercurial
2. vimgdb Vim installation is not required
Decompress the downloaded vim74 source code package, enter the decompressed file directory, and compile
Cd ~ /Downloads/vim74/
. /Configure -- with-features = huge -- enable-rubyinterp -- enable-pythoninterp -- with-python-config-dir =/usr/lib/python2.7/config-x86_64-linux/-- enable-perlinterp -- enable -gui = gtk2 -- enable-CSTE -- enable-luainterp -- enable-multibyte -- enable-xim -- prefix =/usr
Parameter description:
-- With-features = huge: Maximum features supported
-- Enable-rubyinterp: enable Vim to support plug-ins written in ruby.
-- Enable-pythoninterp: enable Vim to support python-compiled plug-ins
-- Enable-luainterp: enable Vim to support plug-ins written by lua.
-- Enable-perlinterp: enable Vim to support perl-compiled plug-ins
-- Enable-multibyte and -- enable-xim: enter Chinese Characters in Vim to enable these two features.
-- Enable-csable: Vim supports cscope
-- Enable-gui = gtk2: supported by gtk2. You can also use gnome to generate gvim
-- With-python-config-dir =/usr/lib/python2.7/config-x86_64-linux-gnu/Specify the python path, which is the path of python2 on the Ubuntu 64-bit host, 32-bit should be/usr/lib/python2.7/config-i386-linux-gnu/
-- Prefix =/usr: Set the compiling and installation path, and check whether you have access permission.
If configure fails, use make distclean to clear the files generated by configure before configure.
Finally, make and install it. Because the set path/usr common user does not have the write permission, sudo must be used for installation.
You can run make without specifying VIMRUNTIMEDIR.
Make VIMRUNTIMEDIR =/usr/share/vim/vim74
Sudo make install
If you want to uninstall suo, make uninstall the following.
Check whether the installation is successful. Run vim -- version to check whether some features are enabled. The feature with the plus sign is enabled.
Iii. Install vim with vimgdb
1. Install vim
Decompress the source code package of vim74 and the patch package of vimgdb to ome Downloads.
?
1
2
3
4
5
:~ /Downloads $ ls
Vim74
Vim-7.4.tar.bz2
Vimgdb-for-vim7.4-master
Vimgdb-for-vim7.4-master.zip
Switch to the current directory and install patches.
Patch-p0 <vimgdb-for-vim7.4-master/vim74.patch
Next, go to vim74/src and make to install the SDK.
Cd vim74/src
Make
Sudo make install
By default, Makefile settings in the current directory can meet General requirements. If you need to add a path or make some modifications, you only need to edit the file. I changed the PATH, because the default/opt/bin PATH is not in my $ PATH, but the vim binfile is put here by default, the command cannot be found when vim is executed. If you do not modify the PATH, add it to $ PATH.
Open it, search for/opt, and comment out the BINDIR, MANDIR, and DATADIR lines according to the annotations. The three rows after the change are as follows:
# Uncomment the next line to install Vim in "/usr/bin"
# BINDIR =/opt/bin
# Uncomment the next line to install Vim manuals in "/usr/share/man/man1"
# MANDIR =/opt/share/man
# Uncomment the next line to install Vim help files in "/usr/share/vim"
# DATADIR =/opt/share
Then make installation. Although I successfully installed it on my ubuntu, but failed to execute vim, there were errors such as "Vim: Caught deadly signal ABRT. The solution is to add CFLAGS = "-O2-D_FORTIFY_SOURCE = 1" in make, then:
Make CFLAGS = "-O2-D_FORTIFY_SOURCE = 1"
Run sudo make install, and then install vim under/usr/local/share/vim/vim74.
If you want to set some features and installation paths by running configure, add -- enable-gdb and run it in the vim74/src directory, if no vimgdb is added, execute configure in the vim74 directory.
. /Configure -- with-features = huge -- enable-rubyinterp -- enable-pythoninterp -- with-python-config-dir =/usr/lib/python2.7/config-x86_64-linux/-- enable-perlinterp -- enable -gui = gtk2 -- enable-CSTE -- enable-luainterp -- enable-multibyte -- enable-xim -- enable-gdb -- prefix =/usr
Check BINDIR, MANDIR, and DATADIR in Makefile to make sure that the three lines are commented out. Then make, add VIMRUNTIMEDIR, and install:
Make VIMRUNTIMEDIR =/usr/share/vim/vim74 CFLAGS = "-O2-D_FORTIFY_SOURCE = 1"
Sudo make install
The installed vim directory is in/usr/share/vim/vim74.
Run vim -- version to check whether there is a plus sign before the following gdb feature. If yes, vimgdb is successfully installed.
2. Install the vimgdb Runtime Environment
Modify (cd ~ /. Vimrc or cd/home/user name/. vimrc) in the main directory. vimrc (If NO, create one)
Join
Let g: vimgdb_debug_file = ""
Run macros/gdb_mappings.vim
Map <F2>: run macros/gdb_mappings.vim <CR>
Here, because the shortcut key F7 of vimgdb conflicts with c-support, I changed it,
In this way, you can load the map of vimgdb by pressing F2 as needed, and then F7 will work normally.
Finally, modify it.
Sudo gedit/usr/share/vim/vim74/macros/gdb_mappings.vim file,
Comment out the last line "call s: Toggle ()", and add an English double quotation mark (double quotation mark) as the comment.
Copy the file under the vimgdb-for-vim7.4-master/vimgdb_runtime to the runtime path ). In vim, run: set runtimepath? To find the runtimepath. Run echo $ VIMRUNTIME to view the installation path. We can see that there are several paths ,~ /. Vim is under the current user, and/usr/share/vim/vim74 is for all users (this is after the installation path is set, the default path should be in/usr/share/vim/vim74 ).
Switch to the selected vim runtime path, open vim, and execute ": helptags." (note that there is no quotation mark. There is a space and a point behind helptags, and the point indicates the current directory .), In this way, you can use ": help vimgdb" to open the help document of vimgdb.
For more Vim tutorials, see the following:
Build Vim into a simple and practical IDE
Vim Learning Guide
Quick learn Vi Editor
Powerful Vim Editor
Build a Vim Development Environment on CentOS 6.2
Install the highlighted Vim editing tool in CentOS 5.4
Vim tips: C language settings
Set the Vim row number in Ubuntu
Vim editor basic tutorial