Once you have downloaded the source and installed the desired external interfaces, it is time to compile the program. We will assume for the following instructions that you acquired the source via CVS and so the files are found in C:\TEMP\Vim.
The file feature.h can be edited to match your preferences, though you can skip this to get the default behavior, which should be fine for most people. You can also enable various features by supplying arguments to the make command during the compilation.
All the supported compilers provide a command-line method for compiling Vim. The Vim source contains a makefile in C:\TEMP\Vim\src for each compiler. These makefiles provide options specific to each compiler, as well as a common set of options available to all the makefiles. The files are Make_mvc.mak and Make_ivc.mak (Microsoft Visual C++), Make_bc5.mak (Borland C++ 5.x), Make_ming.mak (MinGW GCC) and Make_cyg.mak (Cygwin GCC). These files have been supplied by George V. Reilly, Ben Singer, Ken Scott and Ron Aaron and have been well tested.
The options for the compiler can be set in three different ways.
1) The simplest is to edit the makefile directly and comment/uncomment the options to build exactly what you want. The problem with this method is that your changes may be lost by updating the files with newer patches.
2) The second method is to define environment variables for the options. For example, to build a GUI and OLE-enabled Vim with the MSVC++ compiler, you could issue the commands:
C:\TEMP\VIM\SRC>set GUI=yes C:\TEMP\VIM\SRC>set OLE=yes C:\TEMP\VIM\SRC>nmake -f Make_mvc.mak |
The options would remain in effect for any subsequent builds from the same console window. To change a setting you would change the environment variable.
3) Finally, you can specify the options on the command line itself, like:
C:\TEMP\VIM\SRC>make -f Make_cyg.mak GUI=yes OLE=yes |
If you compile with one set of options and decide to add or remove an option, you will want to do a 'clean' to delete the already-compiled object files. If not, you will probably get errors when compiling or linking the program. Just add 'clean' to the end of the command you used for the compile, and any files generated during the previous compile will be removed. Be sure to include all the same options for the 'clean' as you did for the compile, otherwise you may not get all the right files removed. To clean up after the compile from example three above, use the command:
C:\TEMP\VIM\SRC>make -f Make_cyg.mak GUI=yes OLE=yes clean |
Attempts have been made to use the same option name for the same feature in each makefile. Enable or disable the feature with a yes or no option. Features common to all the makefiles are:
Option | Description | Default |
---|---|---|
GUI | 'yes' builds a GUI Vim, 'no' builds a console Vim. | yes |
OLE | 'yes' builds an OLE-enabled Vim. | no |
ICONV | 'yes' dynamically loads libiconv.dll to do character encoding conversions. | yes |
GETTEXT | Dynamically load the gettext library libintl.dll for multilanguage support. | yes |
MBYTE | Enables multibyte support (viewing, not input) | no |
IME | Enables IME support | yes |
DYNAMIC_IME | Loads the imm32.dll library dynamically | yes |
CSCOPE | Enables support for the Cscope interface to Vim. | yes |
DEBUG | 'yes' builds an executable with debug support | no |
CPUNR | Specifies the target CPU for the executable. MSVC++, BCC 5.5, and GCC 2.95.x allow i386 through i686, while GCC 3.x.x adds options for pentium2, pentium3, pentium4, athlon, etc. (Check the gcc man page for all the supported targets) | i386 |
OPTIMIZE | Specifies the optimization level of the executable. Available settings are SPACE (for the smallest executable, SPEED (for a well-balanced executable), and MAXSPEED (for a large but fast executable). | MAXSPEED |
POSTSCRIPT | Enables Postscript output for the :hardcopy command | no |
FEATURES | Specifies what optional features to use, as given in feature.h of the Vim source. Available options are TINY, SMALL, NORMAL, BIG, and HUGE | BIG |
WINVER | Specifies the minimum version of Windows supported by the binary. 0x400 means the binary will run on anything from Win95 on up. 0x500 requires Win2k or higher. | 0x400 |
NETBEANS | Enables the Netbeans integration interface to allow Gvim to be used as the editor for the Netbeans IDE. This option also allows integration with the Agide GUI of the A-A-P project. | yes |
XPM | Specifies the location of the XPM headers and library. This option allows Gvim to display XPM graphics with the 'signs' feature. | |
PERL | Specifies the directory where Perl is installed. | |
PERL_VER | Specifies the version of Perl being used. | 56 |
DYNAMIC_PERL | Indicates whether to statically link the Perl runtime to Vim or to dynamically load it only when needed. | yes |
PYTHON | Specifies the directory where Python is installed. | |
PYTHON_VER | Specifies the version of Python being used. | 22 |
DYNAMIC_PYTHON | Indicates whether to statically link the Python runtime to Vim or to dynamically load it only when needed. | yes |
RUBY | Specifies the directory where Ruby is installed. | |
RUBY_VER | Specifies the version of Ruby being used. | 16 |
RUBY_VER_LONG | Specifies the "long" version of Ruby being used. | 1.6 |
DYNAMIC_RUBY | Indicates whether to statically link the Ruby runtime to Vim or to dynamically load it only when needed. | yes |
RUBY_PLATFORM | Platform for which this version of Ruby was compiled. The default is for Ruby 1.6. For Ruby 1.8 or higher, the default is i386-mswin32. | i586-mswin32 |
RUBY_INSTALL_NAME | The name of the main Ruby DLL. For Ruby 1.6, the default value is mswin32-ruby16 and for Ruby 1.8 or higher the default is msvcrt-ruby18. | mswin32-ruby16 |
TCL | Specifies the directory where Tcl is installed. | |
TCL_VER | Specifies the version of Tcl being used. | 83 |
TCL_LONG_VER | Specifies the "long" version of Tcl being used. | 8.3 |
DYNAMIC_TCL | Indicates whether to statically link the Tcl runtime to Vim or to dynamically load it only when needed. | yes |
Vim can be compiled for Win32 systemss using various versions of the Microsoft Visual C++ (versions 4-7), Borland (version 5 and 5.5), or GCC (2.95.x and 3.x.x from Cygwin or MinGW32). Each compiler has its own makefile and its own set of options and features it provides in addition to the ones listed above.
Microsoft's Visual C++ program is a commercial product and is not available for download. You have two options when compiling Vim with MSVC++: command line and IDE.
The most flexible method for compiling Vim from the command line is to use the Make_mvc.mak file. The advantage of using this makefile instead of Make_ivc.mak is that you have much greater control over the options used to compile Vim. Extra options available are:
Option | Description | Default |
---|---|---|
GIME | Enables global IME support | no |
MAP | Create a mapfile during compilation | yes |
SNIFF | Enable the SNiFF+ interface | no |
VC6 | Delays loading seldom-used DLLs to improve startup time | no |
To debug an executable built with Make_mvc.mak in the MSDev IDE, you need to use Make_dvc.mak in the IDE. From Make_mvc.mak:
Make_mvc.mak gives a fineness of control which is not supported in Visual C++ configuration files. Therefore, debugging requires a bit of extra work. Make_dvc.mak is a Visual C++ project to access that support. To use Make_dvc.mak:
Build Vim with Make_mvc.mak. Use a "DEBUG=yes" argument to build Vim with debug support. E.g. the following builds gvimd.exe:
C:\TEMP\Vim\src>nmake -f Make_mvc.mak debug=yes gui=yes |
Use MS Devstudio and set it up to allow that file to be debugged:
Pass Make_dvc.mak to the IDE. Use the
-> menu entry to load Make_dvc.mak. Alternatively, from the command line:C:\TEMP\Vim\src>msdev /nologo Make_dvc.mak |
C:\TEMP\Vim\src>msdev /nologo Make_dvc.dsw |
Set the built executable for debugging:
-> (Alt-F7) takes you to the Debug dialog.
Fill "Executable for debug session". e.g. gvimd.exe
Fill "Program arguments". e.g. -R dosinst.c
Click
to close the dialogYou can now debug the executable you built with Make_mvc.mak
Note: Make_dvc.mak builds vimrun.exe, because it must build something to be a valid makefile.
Vim can be compiled in the MSDev IDE using the Make_ivc.mak makefile. From the IDE, go to
-> and select Make_ivc.mak and click . You can then select targets such as Release and/or Debug version of Console Vim or GUI Vim.Make_ivc.mak must be in the DOS file format to successfully be opened by the MSDev IDE. If you get your source from the tar archives or CVS, you will have to convert the file to DOS format using a unix2dos utility. If you have a previous version of Vim installed, then an alternative to the unix2dos utiltity would be the command
C:\TEMP>vim -c ":set nomore | bufdo set ff=dos | w" -c q <filenames> |
C:\TEMP>gzip -c %1 | gzip -acd > %2 |
You can also use Make_ivc.mak to compile from the command line, though you are very limited in the types of executables you can build. Issuing the command
C:\TEMP\Vim\src>nmake -f Make_ivc.mak CFG="Vim - Win32 Release gvim OLE" |
CFG="Vim - Win32 Debug gvim OLE" |
CFG="Vim - Win32 Release gvim" |
CFG="Vim - Win32 Debug gvim" |
CFG="Vim - Win32 Release vim" |
CFG="Vim - Win32 Debug vim" |
Borland C++Builder 5.0 can be purchased at a local retailer, or the Borland C++ 5.5 command line tools and two service packs are available for download from http://www.borland.com/products/downloads/download_cbuilder.html (While there, you may want to pick up the Borland TurboDebugger). Use the Make_bc5.mak makefile to build Vim using either of these compilers. Extra options available are:
Option | Description | Default |
---|---|---|
BOR | Specifies the installation directory of the BCC Compiler. | C:\BC5 |
LINK | Specifies the name of the linker | $(BOR)\bin\ilink32 |
OSTYPE | Build a Win32 executable | WIN32 |
CODEGUARD | Enables CodeGuard support in the executable | no |
USEDLL | Use the Borland runtime dll. Reduces size of the executable, but requires cc3250.dll to be in the PATH | no |
VIMDLL | Creates a backend vim32.dll with a stub frontend executable. | no |
ALIGN | Specifies byte alignment | 4 |
FASTCALL | Use register based parameter passing for function calls. Improves performance, but breaks interface to external DLLs, thus is disabled when also compiling with PERL, PYTHON, RUBY, or TCL support. | yes |
To build a TCL-enabled vim with DYNAMIC_TCL=yes, you need to download a stub library for version 8.3.x (http://mywebpage.netscape.com/sharppeople/vim/tclstub83-bor.lib) or 8.4.x (http://mywebpage.netscape.com/sharppeople/vim/tclstub84-bor.lib) due to the difference in binary formats between MSVC++ and BCC compiled programs.
If you are using a 5.0x version compiler, you will need to convert the vim.rc file from Unix to DOS format if you did not get it from the zip archives. You can do this with a unix2dos utility as described above in the MSVC++ IDE section.
The MinGW collection can be downloaded from http://www.mingw.org . Use the Make_ming.mak makefile to build Vim with the MinGW GCC compiler. A special feature of this makefile is the ability to cross-compile a Win32 executable from Linux. Features include:
Option | Description | Default |
---|---|---|
ARCH | Specifies the target ARCH for the executable. GCC 2.95.x allows i386 through i686, while GCC 3.x.x adds options for pentium2, pentium3, pentium4, athlon, etc. Check the gcc man page for all the supported targets. | i386 |
CROSS | Cross-compile from UNIX. | no |
NLS support with Mingw (by Eduardo F. Amatria <eferna1 at platea.pntic.mec.es>):
If you want National Language Support, read the file src/po/README_mingw.txt. You need to uncomment lines in Make_ming.mak to have NLS defined.
(written by Ron Aaron: <ron at mossbayeng.com> with help from Martin Kahlert <martin.kahlert at infineon.com>)
If you like, you can compile the MinGW Win32 version from the comfort of your Linux (or other unix) box. To do this, you need to follow a few steps:
Install the MinGW32 cross-compiler (if you have it, go to step 2)
From ftp://ftp.nanotech.wisc.edu/pub/khan/gnu-win32/mingw32/snapshots/gcc-2.95.2-1, get:
binutils-19990818-1-src.tar.gz |
mingw-msvcrt-20000203.zip |
gcc-2.95.2-1-x86-win32.diff.gz |
From http://gcc.gnu.org/ get:
gcc-2.95.2.tar.gz |
Create a place to put the compiler source and binaries (assuming you are in the home directory):
$ mkdir gcc-bin $ mkdir gcc-src |
Unpack the sources:
$ cd gcc-src $ tar xzf ../binutils-19990818-1-src.tar.gz $ tar xzf ../gcc-2.95.2.tar.gz $ unzip ../mingw-msvcrt-20000203 |
Build the different tools:
$ export PREFIX=~/gcc-bin/ $ cd gcc-2.95.2 $ zcat ../gcc-2.95.2-1-x86-win32.diff.gz | patch -p1 -E $ cd ../binutils-19990818 $ ./configure --target=i586-pc-mingw32msvc --prefix=$PREFIX $ make $ make install $ cd ../gcc-2.95.2 $ ./configure --target=i586-pc-mingw32msvc \ $ --with-libs=~/gcc-bin/i386-mingw32msvc/lib \ $ --with-headers=~/gcc-bin/i386-mingw32msvc/include \ $ --enable-languages=c++ \ $ --prefix=$PREFIX $ make $ make install |
Add $PREFIX/bin to your $PATH.
Get the unix version of the vim sources from the tar archives.
In Make_ming.mak, set CROSS to 1 instead of 0.
Start your compile:
$ make -f Make_ming.mak gvim.exe |
Now you have created the Windows binary from your Linux box! Have fun...
If you are cross-compiling on Linux with the mingw32 setup and are including the Perl, Python, Ruby, or TCL interfaces, you need to also convert each interpreter's include files to unix line-endings. This bash command will do it easily:
$ for fil in *.h ; do vim -e -c 'set ff=unix|w|q' $fil |
If for some reason you want to build an executable that does not dynamically load the interpreter DLLs, you need to do a little extra work. Libraries compiled by MSVC++ (like those in the ActiveState distributions) do not link well with GCC. You need to manually create a GCC-compatible library.
The following instruction were originally written by Ron Aaron <ron at mossbayeng.com> for the Python interpreter, but the same instructions apply to other interpreters as well.
This has been tested with the MinGW32 compiler, and the ActiveState ActivePython: http://www.ActiveState.com/Products/ActivePython/
After installing the ActivePython, you will have to create a 'MinGW32' libpython20.a to link with:
$ cd $PYTHON/libs $ pexports python20.dll > python20.def $ dlltool -d python20.def -l libpython20.a |
Once that is done, edit the Make_ming.mak so the PYTHON variable points to the root of the Python installation (C:\Python20, for example). If you are cross-compiling on Linux with the MinGW32 setup, you need to also convert all the 'Include' files to *unix* line-endings. This bash command will do it easily:
$ for fil in *.h ; do vim -e -c 'set ff=unix|w|q' $fil |
Now just do:
$ make -f Make_ming.mak gvim.exe |
The Cygwin collection is available from http://www.cygwin.com and provides a Unix-like operating environment under Win32.
One important item to mention here is that Cygwin can compile two different types of Vim that will run under Windows. One type is a Unix application, the other is a Win32 application. Differences are as follows:
The Win32 version is compiled with the Make_cyg.mak makefile, while the Unix version uses the standard ./configure; make;make install process.
The Win32 version compiles a GUI application that runs like any other native Windows app. The Unix version has GUI support, but it requires an X server (like XFree86) to compile and use it.
The Win32 version understands normal DOS paths, like C:\Windows. The Unix version understands Unix / Cygwin paths like /var/log or C:/Windows.
Currently there is no way (and no plans to implement a way) to have a version that runs like the Unix version but sports a native Win32 GUI. With the cygpath.exe utility in the Cygwin distribution and a little work, though, you can help the Win32 version understand Unix / Cygwin paths. Search the tips at http://www.vim.org and the Vim Mailing List Archives at http://groups.yahoo.com/group/vim for information on how to do this.
With the release of XFree86 4.3.0, the Cygwin X server offers two new options, -rootless and -multiwindow. These options allow you to run X programs and have them managed by the native Windows window manager, so they appear like any other standard Windows application.
Use the Make_cyg.mak makefile to build Vim with the Cygwin GCC compiler. The initial version of this makefile only supports building a vanilla console Vim (or a vanilla GUI Vim after editing the makefile). Patch 6.1.253 adds many more features to this makefile. In addition to the common ones listed above, it also provides:
Option | Description | Default |
---|---|---|
ARCH | Specifies the target ARCH for the executable. GCC 2.95.x allows i386 through i686, while GCC 3.x.x adds options for pentium2, pentium3, pentium4, athlon, etc. Check the gcc man page for all the supported targets. | i386 |
USEDLL | Use the Cygwin runtime DLL. Reduces the size of the executable, but requires that cygwin1.dll be in the PATH. | no |
Once you compile your binaries, you are ready to go. In the C:\TEMP\vim\src directory you should have either a vim.exe and / or a gvim.exe, as well as install.exe, uninstal.exe, and vimrun.exe. There is also xxd.exe in C:\TEMP\vim\src\xxd and gvimext.dll in C:\TEMP\vim\src\GvimExt. If you want, you can do a couple more steps to round out your installation.
Installing gvimext.dll will add the "Edit with Vim" set of entries to the context menu when you right-click on files. Prior to version 6.2, you had to manually compile the DLL from the C:\TEMP\vim\GvimExt directory. As of 6.2, though, the DLL is compiled as part of the normal build process. To compile it by itself, just go to the C:\TEMP\vim\src\GVimExt directory and read the README.txt for instructions.
If you use Visual Studio 6, you may also be interested in the visvim.dll extension, which will help integrate Vim into the MSDev IDE (version 6). Go to C:\TEMP\vim\VisVim and read the README.txt for instructions on compiling (MSVC++ only) and installing the DLL.
One final step you may want to take is to compress your binaries. The UPX utility (available from http://upx.sf.net will compress each executable to approximately 50% of its original size without creating a noticable penalty in startup time. The MinGW makefile includes a target to run UPX on the compiled Vim or GVim binary. For the others, you can compress all the executable files with the command
C:\TEMP\Vim\src>copy xxd\xxd.exe . && upx *.exe |