# 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:

• install all of CygWin (Note that you don’t really need all of Cygwin; in fact I think you just need a few simple programs like cp and mv, and the shell. But I don’t know exactly what those programs are, and I tend to use all of Cygwin already anyway.)
• install just MinGW-3.1.0-1.exe
• check out emacs (use a Cygwin shell for this):
``` cd /usr/local
mkdir src
cd src
cvs -d :pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co emacs```
• build it (use a Cygwin shell for this, too):
``` cd emacs/nt
PATH=/c/mingw/bin:\$PATH
/c/mingw/bin/make
/c/mingw/bin/make recompile
/c/mingw/bin/make install```
• I followed your steps I got this error:
``` \$ 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 ````
• Any ideas?

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

• JPEG support
• Required files: jpeg62.dll, jconfig.h (in bin & lib packages)
• Current: jpeg-6b-4-bin.zip, jpeg-6b-4-lib.zip
• GIF support
• Required files: libungif.dll, gif_lib.h (in bin & src packages)
• Current: libungif-4.1.0b1-bin.zip, libungif-4.1.0b1-src.zip
• TIFF support
• Required files: libtiff3.dll, tiffio.h, tiff.h, tiffvers.h (in bin & lib packages)
• Current: tiff-3.7.2-bin.zip, tiff-3.7.2-lib.zip
• XPM support
• Required files: xpm4.dll, X11/xpm.h, simx.h (in bin & lib & src packages)
• Current: xpm-3.5.1-1-bin.zip, xpm-3.5.1-1-lib.zip, xpm-3.5.1-1-src.zip
• PNG support
• Required files: libpng13.dll, png.h, pngconf.h (in bin & lib packages)
• Current: libpng-1.2.8-bin.zip, libpng-1.2.8-lib.zip
• Zlib (required by PNG)
• Required files: zlib1.dll (in bin packages)
• Current: zlib-1.2.2-bin.zip

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.