The steps outlined in this entry describe A way that works for me to build
and install GNU Emacs on Windows Vista from source code. For alternatives,
please review the
INSTALL file located in the nt folder of the emacs source
tree. The approach I take is to enumerate the steps in a “do this, then this,
then this…” fashion. I don’t go into the reasons and technical details of each
step here, but I do provide a list of resources at the end where you can find
the technical background behind the process I outline below.
I also should mention that the EmacsW32 guys distribute GNU Emacs in a Windows Installer. There you can choose the patched or unpatched versions of the package. The patched version provides better integration with Windows, but I use the unpatched version because I am an emacs purist. I recommend this package if you need to run emacs on Windows and don’t want to build it from the source code. What I really like about the EmacsW32 package is that it's kept at the latest emacs snapshot available.
Now, on with the show… The required prerequisites for this build are the following:
- A Windows Vista SP1 Installation.
- A CVS client. I use the Cygwin version.
- The latest GNU Emacs sources from the CVS repository.
- The 5.1.4 MinGW version of GCC & Tools.
- The GNU Win32 core utilities.
The following optional prerequisites are needed if you want to build emacs with image support:
And finally, the steps:
- Download and install a CVS client. I use the one that comes with Cygwin (see link above).
Get the latest version of GNU Emacs from the CVS repository by running the following instruction on the Windows command line:
cvs -z3 -d:pserver:email@example.com:/sources/emacs co emacs
This command will create a working folder called emacs in the current directory.
Download and install the latest version of the MinGW compiler and Make tool. There is a Windows installer provided at the link listed above. At a minimum you will need the core GCC and the Make tool.
Add the bin folder of the MinGW installation to your path. On my machine I did that by running this statement on the command line:
Download and install the GNUWin32 core utilities from the link above.
Add the bin folder of the GNUWin32 installation to your path. This can be done by running a command similar to this one:
The following steps are optional and only needed if you wish to compile emacs with image support:
- Download and install all the libraries listed in the optional requirements area above. All of these libraries are provided as a Windows installer. I install them in the same location where I installed the GNUWin32 core utilities.
- For the XPM library you will also need to download the source code, which comes in a zip compressed file.
- Unzip the XPM library source code.
- Find the file named simx.h and copy it to the include folder under your GNUWin32 installation.
From the Windows command line, go into the emacs working folder you got from CVS and then go into the nt folder.
In the nt folder, run the following command:
cvs update -kb
This will ensure that the newline characters in the files are correct for Windows.
From the nt folder, issue the following command:
configure.bat --no-debug --with-gcc
... or if you wish to compile emacs with image support issue the following command:
configure.bat --cflags -IC:\gnuwin32\include --no-debug --with-gcc
Where the argument after the -I parameter is the path to the header files for the image libraries you just installed. This will effectively prepare the build process for your system.
Initially, we need to do a bootstrap build by running the following command:
This is necessary in order to build the emacs lisp interpreter and compile all the .el files. This may take a few minutes, so this is a good point for a break.
Now you should run make alone again to make sure you caught everything:
The last step in this process is to install the build you just finished. To do this run the following command:
mingw32-make install INSTALL_DIR=C:/emacsfromcvs
Where the INSTALL_DIR value is the location where you want to install emacs.
I hope you find this entry useful and concise. If you want more information on the topic of building GNU Emacs from source, please refer to these resources:
- Building Emacs on MS Windows at EmacsW32.
- GNU Emacs FAQ for MS Windows by the GNU Project.
- The INSTALL file in the nt folder of the emacs source tree.
P.S.: I specifically omitted a step in the process described above. That's
the step that calls
minwg32-make info which builds the Info manuals. Reason
being is that makeinfo.exe is crashing on my system. When I open
makeinfo.exe in the VS2008 debugger I get the following error message:
Unhandled exception at 0x00425425 in makeinfo.exe: 0xC0000005: Access violation
reading location 0x00000000. Looks like a null pointer problem to me.