How to build vim with gui option from sources?

Solution 1:

To build Vim you will need first to install all the dependencies. This could be done using

$ sudo apt-get build-dep vim-gtk # or vim-gnome, if you prefer.

This will download and install a lot of packages that should only be needed to compile Vim. If you don't want to keep them, before running that command add this to /etc/apt/apt.conf

APT {
  Get {
     Build-Dep-Automatic "true";
  };
};

This will make all the packages installed with build-dep be "marked to be autoremoved". So after you finished compiling Vim you can uninstall them using sudo apt-get autoremove.

After this, just proceed with the usual steps:

$ ./configure --with-gui=gtk2 # or gnome
$ make -j 4
$ sudo make install  

Solution 2:

If you call ./configure --enable-gui=auto, the build process will automatically build against whichever GUI libraries are available. A cursory glance suggests that gtk2 will be prioritised over gnome2.