Building & Installing GNU Emacs from Source in Windows Vista

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:

The following optional prerequisites are needed if you want to build emacs with image support:

And finally, the steps:

  1. Download and install a CVS client. I use the one that comes with Cygwin (see link above).
  2. 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:anonymous@cvs.savannah.gnu.org:/sources/emacs co emacs
    

    This command will create a working folder called emacs in the current directory.

  3. 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.

  4. 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:

    set PATH=C:\MinGW\bin;%PATH%
    
  5. Download and install the GNUWin32 core utilities from the link above.

  6. Add the bin folder of the GNUWin32 installation to your path. This can be done by running a command similar to this one:

    set PATH=%PATH%;C:\gnuwin32\bin
    
  7. The following steps are optional and only needed if you wish to compile emacs with image support:

    1. 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.
    2. For the XPM library you will also need to download the source code, which comes in a zip compressed file.
    3. Unzip the XPM library source code.
    4. Find the file named simx.h and copy it to the include folder under your GNUWin32 installation.
  8. From the Windows command line, go into the emacs working folder you got from CVS and then go into the nt folder.

  9. 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.

  10. 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.

  11. Initially, we need to do a bootstrap build by running the following command:

    mingw32-make bootstrap
    

    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.

  12. Now you should run make alone again to make sure you caught everything:

    mingw32-make
    
  13. 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:

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.

Comments

Comments powered by Disqus