BuildingCvsWThirtyTwoMingw

BuildingEmacsWithMinGW talks about the same things as this page, but that page is just a batch file. I’ve been building CVS Emacs for Win32, using a mixture of CygWin and MinGW, regularly for months. Here’s what I did:

 cd /usr/local
 mkdir src
 cd src
 cvs -d :pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co emacs
 cd emacs/nt
 PATH=/c/mingw/bin:$PATH
 /c/mingw/bin/make
 /c/mingw/bin/make recompile
 /c/mingw/bin/make install
 $ make
 [Please ignore a syntax error on the next line - it is intentional]
 /bin/sh.exe: -c: line 1: unexpected EOF while looking for matching `"'
 /bin/sh.exe: -c: line 2: syntax error: unexpected end of file
 ', needed by `which-sh'.  Stop.t `

A guide for building Emacs with MinGW

I have put together a beginners guide for building CVS Emacs with MinGW. This guide is available in EmacsW32 and at the website mentioned on that page. You do not have to use Cygwin with this guide. The guide mentions what you need instead. Too make it a bit easier I have also made a small perl script to check the building environment and a cmd file to automate it all from checkout CVS to installation.

I have found the guide below for images support very good so I have shamelessly included it in my guide above.

A guide for images support

Several images library is necessory for images support in CVS Emacs. All of them can be downloaded at http://gnuwin32.sf.net. Both the bin packages(for .dll files) and the lib or src packages(for .h files) should be downloaded first. Files of .dll is for runtime, and .h for compiling.

You still need to copy the simx.h from src\xpm\3.5.1\libXpm-3.5.1-src\lib to the include\ directory of your gnuwin32 installation. configure.bat throws an error “linker input file unused because linking not done” if you forget to define this preprocessor macro XPM_NO_X as an argument to the configure.bat script. (If you view simx.h using a text editor, you will notice that the functionality depends on XPM_NO_X being defined.)

Assuming all required .h files are in C:\free_ware\gnuwin32\include. Run cmd.exe, then to cvs-emacs\nt directory:

 emacs\nt> configure.bat -h
 emacs\nt> configure.bat --with-gcc --cflags -IC:/free_ware/gnuwin32/include --cflags -IC:/free_ware/gnuwin32/src/lib --cflags -DXPM_NO_X
 emacs\nt> dos2unix makefile
 emacs\nt> make bootstrap

Copy all .dll files to the directory EMACS_INSTALL_DIR\bin, so this Emacs will support images.

Sidenote: On some GNUWin32 installations, you may get build errors. In that case, you can install the libjpeg, libpng, zlib, libtiff, Xpm, and giflib libraries in a separate place (say, C:/gnutemp/), and use this path instead of the one used above (C:/free_ware/gnuwin32/). You can also use the --prefix flag to tell configure.bat where you would like GNU Emacs installed. Also, don’t forget to copy the .dll files in C:/gnutemp/bin to the EMACS_INSTALL_DIR\bin directory as stated above.

Warning: Do NOT append a trailing backslash or forward slash to any of the directory paths in the build commands.