1 Building and Installing Emacs on MS-Windows
2 using the MSYS and MinGW tools
4 Copyright (C) 2013 Free Software Foundation, Inc.
5 See the end of the file for license conditions.
7 The MSYS/MinGW build described here is supported on versions of
8 Windows starting with Windows 2000 and newer. Windows 9X are not
9 supported (but the Emacs binary produced by this build will run on
12 * For the brave (a.k.a. "impatient"):
14 For those who have a working MSYS/MinGW development environment and
15 are comfortable with running Posix configure scripts, here are the
16 concise instructions for configuring and building the native Windows
17 binary of Emacs with these tools.
19 Do not use this recipe with Cygwin. For building on Cygwin, use the
20 normal installation instructions, ../INSTALL.
22 Do not use these instructions if you don't have MSYS installed; for
23 that, see the file INSTALL in this directory.
25 0. Start the MSYS Bash window. Everything else below is done from
26 that window's Bash prompt.
28 0a. If you are building from the development trunk (as opposed to a
29 release tarball), produce the configure script, by typing from
30 the top-level Emacs source directory:
34 1. If you want to build Emacs outside of the source tree
35 (recommended), create the build directory and chdir there.
37 2. Invoke the MSYS-specific configure script:
39 - If you are building outside the source tree:
41 /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
43 - If you are building in-place, i.e. inside the source tree:
45 ./nt/msysconfig.sh --prefix=PREFIX ...
47 It is always preferable to use --prefix to configure Emacs for
48 some specific location of its installed tree; the default
49 /usr/local is not suitable for Windows.
51 You can pass other options to the configure script. Here's a
52 typical example (for an in-place debug build):
54 CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=d:/usr/emacs --enable-checking
56 3. After the configure script finishes, it should display the
57 resulting configuration. After that, type
61 Use "make -j N" if your MSYS Make supports parallel execution;
62 the build will take significantly less time in that case. Here N
63 is the number of simultaneous parallel jobs; use the number of
64 the cores on your system.
66 4. Install the produced binaries:
70 If you want the installation tree to go to a place that is
71 different from the one specified by --prefix, say
73 make install prefix=/where/ever/you/want
77 If these short instructions somehow fail, read the rest of this
80 * Installing MinGW and MSYS
82 Make sure you carefully read the following two sections in their
83 entirety and install/configure the various packages as instructed.
84 A correct installation makes all the rest almost trivial; a botched
85 installation will likely make you miserable for quite some time.
89 You will need to install the MinGW port of GCC and Binutils, and the
90 MinGW runtime and Windows API distributions, to compile Emacs. You
91 can find these on the MinGW download/Base page:
93 https://sourceforge.net/projects/mingw/files/MinGW/Base/
95 In general, install the latest stable versions of the following
96 MinGW packages from that page: gcc, binutils, mingw-rt, w32api. You
97 only need the 'bin' and the 'dll' tarballs of each of the above.
99 A nice GUI installer, called mingw-get, is available for those who
100 don't like to mess with manual installations. You can download it
103 https://sourceforge.net/projects/mingw/files/Installer/mingw-get/
105 (This installer only supports packages downloaded from the MinGW
106 site; for the rest you will still need the manual method.)
108 MinGW and MSYS packages are distributed as .tar.lzma compressed
109 archives. If you like to install the packages manually, then we
110 recommend to use the Windows port of the 'bsdtar' program to unpack
111 the tarballs. 'bsdtar' is available as part of the 'libarchive'
114 http://sourceforge.net/projects/ezwinports/files/
116 The recommended place to install these packages is a single tree
117 starting from some directory on a drive other than the system drive
118 C:. A typical example would be D:\usr, with D:\usr\bin holding the
119 binaries and DLLs (should be added to your Path environment
120 variable), D:\usr\include holding the include files, D:\usr\lib
121 holding the static and import libraries, D:\share holding docs,
122 message catalogs, and package-specific subdirectories, etc.
124 Having all the headers and libraries in a single place will greatly
125 reduce the number of -I and -L flags you will have to pass to the
126 configure script (see below), as these files will be right where the
127 compiler expects them.
129 We specifically do NOT recommend installing packages below
130 "C:\Program Files" or "C:\Program Files (x86)". These directories
131 are protected on versions of Windows from Vista and on, and you will
132 have difficulties updating and maintaining your installation later,
133 due to UAC elevation prompts, file virtualization, etc. You *have*
136 Additional MinGW packages are required/recommended, especially if
137 you are building from the Bazaar repository:
139 . Texinfo (needed to produce the Info manuals when building from bzr)
141 Available from http://sourceforge.net/projects/ezwinports/files/.
143 . gzip (needed to compress files during "make install")
145 Available from http://gnuwin32.sourceforge.net/packages/gzip.htm.
147 . pkg-config (needed for building with some optional image libraries)
149 Available from http://www.gtk.org/download/win32.php
151 Each package might list other packages as prerequisites on its
152 download page (under "Runtime requirements"); download those as
153 well. (Using the GUI installer mingw-get will fetch those
154 prerequisites automatically for you.) A missing prerequisite will
155 manifest itself by the program failing to run and presenting a
156 pop-up dialog that states the missing or incompatible DLL; be sure
157 to find and install these missing DLLs.
159 Once you think you have MinGW installed, test the installation by
160 building a trivial "hello, world!" program, and make sure that it
161 builds without any error messages and the binary works when run.
165 You will also need a reasonably full MSYS installation. MSYS is an
166 environment needed to run the Posix configure scripts and the
167 resulting Makefile's, in order to produce native Windows binaries
168 using the MinGW compiler and runtime libraries. Here's the list of
169 MSYS packages that are required:
171 . All the packages from the MSYS Base distribution, listed here:
173 https://sourceforge.net/projects/mingw/files/MSYS/Base/
175 . Additional packages listed below, from the MSYS Extension
178 https://sourceforge.net/projects/mingw/files/MSYS/Extension/
186 These should only be needed if you intend to build development
187 versions of Emacs from the Bazaar repository.
189 . Additional packages (needed only if building from the Bazaar
190 repository): Automake and Autoconf. They are available from
193 http://sourceforge.net/projects/ezwinports/files/automake-1.11.6-msys-bin.zip/download
194 http://sourceforge.net/projects/ezwinports/files/autoconf-2.65-msys-bin.zip/download
196 If/when you are confident in your MinGW/MSYS installation, and want
197 to speed up the builds, we recommend installing a pre-release
198 version of Make from here:
200 https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
202 These are snapshot builds of many packages, but you only need
203 make.exe from there. The advantage of this make.exe is that it
204 supports parallel builds, so you can use "make -j N" to considerably
207 For each of these packages, install the 'bin' and 'dll' tarballs of
208 their latest stable releases. If there's an 'ext' tarball (e.g.,
209 msysCORE and Coreutils have it), download and install those as well.
211 Each package might list other packages as prerequisites on its
212 download page (under "Runtime requirements"); download those as
213 well. (Using the GUI installer mingw-get will fetch those
214 prerequisites automatically for you.) A missing prerequisite will
215 manifest itself by the program failing to run and presenting a
216 pop-up dialog that states the missing or incompatible DLL; be sure
217 to find and install these missing DLLs.
219 MSYS packages should be installed in a separate tree from MinGW.
220 For example, use D:\MSYS or D:\usr\MSYS as the top-level directory
221 from which you unpack all of the MSYS packages.
223 Do NOT add the MSYS bin directory to your Windows Path! Only the
224 MinGW bin directory should be on Path. When you install MSYS, it
225 creates a shortcut on your desktop that invokes the MSYS Bash shell
226 in a Command Prompt window; that shell is already set up so that the
227 MSYS bin directory is on PATH ahead of any other directory. Thus,
228 Bash will find MSYS executables first, which is exactly what you
231 At this point, you are ready to build Emacs in its basic
232 configuration. If you want to build it with image support, read
233 about the optional image libraries near the end of this document.
235 * Generating the configure script.
237 If you are building a release or pretest tarball, skip this section,
238 because the configure script is already present in the tarball.
240 To build a development snapshot from the Emacs Bazaar repository,
241 you will first need to generate the configure script and a few other
242 auto-generated files. (If this step, described below, somehow
243 fails, you can use the files in the autogen/ directory instead, but
244 they might be outdated, and, most importantly, you are well advised
245 not to disregard any failures in your local build procedures, as
246 these are likely to be symptoms of incorrect installation that will
247 bite you down the road.)
249 To generate the configure script, type this at the MSYS Bash prompt
250 from the top-level directory of the Emacs tree:
254 If successful, this command should produce the following output:
257 Checking whether you have the necessary tools...
258 (Read INSTALL.BZR for more details on building Emacs)
260 Checking for autoconf (need at least version 2.65)...
262 Checking for automake (need at least version 1.11)...
264 Your system has the required tools, running autoreconf...
265 You can now run `./configure'.
267 * Configuring Emacs for MinGW:
269 Now it's time to run the configure script. You can do that either
270 from a separate build directory that is outside of the Emacs source
271 tree (recommended), or from inside the source tree. The former is
272 recommended because it allows you to have several different builds,
273 e.g., an optimized build and an unoptimized one, of the same
274 revision of the source tree; the source tree will be left in its
275 pristine state, without any build products.
277 You invoke the configure script like this:
279 /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
281 or, if you are building in-place, i.e. inside the source tree:
283 ./nt/msysconfig.sh --prefix=PREFIX ...
285 Here PREFIX is the place where you eventually want to install Emacs
286 once built, e.g. d:/usr.
288 You can pass additional options to the configure script, for the
291 ./nt/msysconfig.sh --help
293 As explained in the help text, you may need to tell the script what
294 are the optional flags to invoke the compiler. This is needed if
295 some of your headers and libraries, e.g., those belonging to
296 optional image libraries, are installed in places where the compiler
297 normally doesn't look for them. (Remember that advice above to
298 avoid such situations? here's is where you will start paying for
299 disregarding that recommendation.) For example, if you have libpng
300 headers in C:\emacs\libs\libpng-1.2.37-lib\include and jpeg library
301 headers in C:\emacs\libs\jpeg-6b-4-lib\include, you will need to say
304 CPPFLAGS='-Ic:/emacs/libs/libpng-1.2.37-lib/include -Ic:/emacs/libs/jpeg-6b-4-lib/include' ./nt/msysconfig.sh --prefix=PREFIX
306 which is quite a mouth-full, especially if you have more directories
307 to specify... Perhaps you may wish to revisit your installation
310 A few frequently used options are needed when you want to produce an
311 unoptimized binary with runtime checks enabled:
313 CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=PREFIX --enable-checking
315 Once invoked, the configure script will run for some time, and, if
316 successful, will eventually produce a summary of the configuration
319 Configured for `i686-pc-mingw32'.
321 Where should the build process find the source code? /path/to/emacs/sources
322 What compiler should emacs be built with? gcc -std=gnu99 -O0 -g3
323 Should Emacs use the GNU version of malloc? yes
324 Should Emacs use a relocating allocator for buffers? yes
325 Should Emacs use mmap(2) for buffer allocation? no
326 What window system should Emacs use? w32
327 What toolkit should Emacs use? none
328 Where do we find X Windows header files? NONE
329 Where do we find X Windows libraries? NONE
330 Does Emacs use -lXaw3d? no
331 Does Emacs use -lXpm? yes
332 Does Emacs use -ljpeg? yes
333 Does Emacs use -ltiff? yes
334 Does Emacs use a gif library? yes
335 Does Emacs use -lpng? yes
336 Does Emacs use -lrsvg-2? no
337 Does Emacs use imagemagick? no
338 Does Emacs use -lgpm? no
339 Does Emacs use -ldbus? no
340 Does Emacs use -lgconf? no
341 Does Emacs use GSettings? no
342 Does Emacs use -lselinux? no
343 Does Emacs use -lgnutls? yes
344 Does Emacs use -lxml2? yes
345 Does Emacs use -lfreetype? no
346 Does Emacs use -lm17n-flt? no
347 Does Emacs use -lotf? no
348 Does Emacs use -lxft? no
349 Does Emacs use toolkit scroll bars? yes
351 You are almost there, hang on.
353 If the output is significantly different, or if configure finishes
354 prematurely and displays some error message, you should examine the
355 configuration log in config.log and find the reason for the failure.
357 Once you succeeded in configuring Emacs, and just want to rebuild it
358 after updating your local repository from the main repository, you
359 don't need to re-run the configure script manually, unless you want
360 to change the configure-time options. Just typing "make" will
361 re-run configure if necessary with the exact same options you
362 specified originally, and then go on to invoking Make, described
367 This is simple: just type "make" and sit back, watching the fun.
369 If you installed a snapshot build of Make, the build will be much
370 faster if you type "make -j N" instead, where N is the number of
371 independent processing units on your machine. E.g., on a core i7
372 system try using N of 6 or even 8.
374 When Make finishes, you can install the produced binaries:
378 or, if you want the installed tree to go in a place different from
379 the configured one, type
381 make install prefix=WHEREVER
383 Congrats! You have built and installed your own Emacs!
387 The following make targets may be used by users building the source
388 distribution, or users who have checked out of Bazaar after
389 an initial bootstrapping.
392 Builds Emacs from the available sources and pre-compiled lisp files.
395 Installs the built programs and the auxiliary files.
398 Removes object and executable files produced by the build process in
399 the current configuration. After "make clean", you can rebuild with
400 the same configuration using make. useful when you want to be sure
401 that all of the products are built from coherent sources.
404 In addition to the files removed by make clean, this also removes
405 Makefiles and other generated files to get back to the state of a
406 freshly unpacked source distribution. After make distclean, it is
407 necessary to run the configure script followed by "make", in order
410 The following targets are intended only for use with the Bazaar sources.
413 Removes all the auto-generated files and all the *.elc byte-compiled
414 files, and builds Emacs from scratch. Useful when some change in
415 basic Emacs functionality makes byte compilation of updated files
418 make maintainer-clean
419 Removes everything that can be recreated, including compiled Lisp
420 files, to get back to the state of a fresh Bazaar tree. After make
421 maintainer-clean, it is necessary to run configure and "make" or
422 "make bootstrap" to rebuild. Occasionally it may be necessary to
423 run this target after an update.
425 * Optional image library support
427 In addition to its "native" image formats (pbm and xbm), Emacs can
428 handle other image types: xpm, tiff, gif, png, jpeg and experimental
431 To build Emacs with support for them, the corresponding headers must
432 be in the include path when the configure script is run. This is be
433 set up using the CPPFLAGS and CFLAGS variable specified on the
434 configure command line. The configure script will report whether it
435 was able to detect the headers. If the results of this testing
436 appear to be incorrect, please look for details in the file
437 config.log: it will show the failed test programs and compiler error
438 messages that should explain what is wrong. (Usually, any such
439 failures happen because some headers are missing due to bad
440 packaging of the image support libraries.)
442 Note that any file path passed to the compiler or linker must use
443 forward slashes, or double each backslash, as that is how Bash
446 If the configure script finds the necessary headers, but they are
447 for some reason incompatible, or if you want to omit support for
448 some image library that is installed on your system for some other
449 reason, use the --without-PACKAGE option to configure, such as
450 --without-gif to omit GIF, --without-tiff to omit TIFF, etc.
451 Passing the --help option to the configure script displays all of
452 the supported --without-PACKAGE options.
454 To use the external image support, the DLLs implementing the
455 functionality must be found when Emacs first needs them, either on the
456 PATH, or in the same directory as emacs.exe. Failure to find a
457 library is not an error; the associated image format will simply be
458 unavailable. Note that once Emacs has determined that a library can
459 not be found, there's no way to force it to try again, other than
460 restarting. See the variable `dynamic-library-alist' to configure the
461 expected names of the libraries.
463 Some image libraries have dependencies on one another, or on zlib.
464 For example, tiff support depends on the jpeg library. If you did not
465 compile the libraries yourself, you must make sure that any dependency
466 is in the PATH or otherwise accessible and that the binaries are
467 compatible (for example, that they were built with the same compiler).
469 Binaries for the image libraries (among many others) can be found at
470 the GnuWin32 project. PNG, JPEG and TIFF libraries are also
471 included with GTK, which is installed along with other Free Software
472 that requires it. Note specifically that, due to some packaging
473 snafus in the GnuWin32-supplied image libraries, you will need to
474 download _source_ packages for some of the libraries in order to get
475 the header files necessary for building Emacs with image support.
477 For PNG images, we recommend to use versions 1.4.x and later of
478 libpng, because previous versions had security issues. You can find
479 precompiled libraries and headers on the GTK download page for
480 Windows (http://www.gtk.org/download/win32.php).
482 Versions 1.4.0 and later of libpng are binary incompatible with
483 earlier versions, so Emacs will only look for libpng libraries which
484 are compatible with the version it was compiled against. That
485 version is given by the value of the Lisp variable `libpng-version';
486 e.g., 10403 means version 1.4.3. The variable `dynamic-library-alist'
487 is automatically set to name only those DLL names that are known to
488 be compatible with the version given by `libpng-version'. If PNG
489 support does not work for you even though you have the support DLL
490 installed, check the name of the installed DLL against
491 `dynamic-library-alist' and the value of `libpng-version', and
492 download compatible DLLs if needed.
494 * Optional GnuTLS support
496 If the configure script finds the gnutls/gnutls.h file in the
497 include path, Emacs is built with GnuTLS support by default; to
498 avoid that you can pass the argument --without-gnutls.
500 In order to support GnuTLS at runtime, a GnuTLS-enabled Emacs must
501 be able to find the relevant DLLs during startup; failure to do so
502 is not an error, but GnuTLS won't be available to the running
505 You can get pre-built binaries (including any required DLL and the
506 header files) at http://sourceforge.net/projects/ezwinports/files/.
508 * Optional libxml2 support
510 If the configure script finds the libxml/HTMLparser.h file in the
511 include path, Emacs is built with libxml2 support by default; to
512 avoid that you can pass the argument --without-libxml2.
514 In order to support libxml2 at runtime, a libxml2-enabled Emacs must
515 be able to find the relevant DLLs during startup; failure to do so
516 is not an error, but libxml2 features won't be available to the
519 One place where you can get pre-built Windows binaries of libxml2
520 (including any required DLL and the header files) is here:
522 http://sourceforge.net/projects/ezwinports/files/
524 For runtime support of libxml2, you will also need to install the
525 libiconv "development" tarball, because the libiconv headers need to
526 be available to the compiler when you compile with libxml2 support.
527 A MinGW port of libiconv can be found on the MinGW site:
529 http://sourceforge.net/projects/mingw/files/MinGW/Base/libiconv/
531 You need the libiconv-X.Y.Z-N-mingw32-dev.tar.lzma tarball from that
534 * Experimental SVG support
536 SVG support is currently experimental, and not built by default.
537 Specify --with-rsvg and ensure you have all the dependencies in your
538 include path. Unless you have built a minimalist librsvg yourself
539 (untested), librsvg depends on a significant chunk of GTK+ to build,
540 plus a few Gnome libraries, libxml2, libbz2 and zlib at runtime. The
541 easiest way to obtain the dependencies required for building is to
542 download a pre-bundled GTK+ development environment for Windows.
544 To use librsvg at runtime, ensure that librsvg and its dependencies
545 are on your PATH. If you didn't build librsvg yourself, you will
546 need to check with where you downloaded it from for the
547 dependencies, as there are different build options. If it is a
548 short list, then it most likely only lists the immediate
549 dependencies of librsvg, but the dependencies themselves have
550 dependencies - so don't download individual libraries from GTK+,
551 download and install the whole thing. If you think you've got all
552 the dependencies and SVG support is still not working, check your
553 PATH for other libraries that shadow the ones you downloaded.
554 Libraries of the same name from different sources may not be
555 compatible, this problem was encountered with libbzip2 from GnuWin32
556 with libcroco from gnome.org.
558 If you can see etc/images/splash.svg, then you have managed to get
559 SVG support working. Congratulations for making it through DLL hell
560 to this point. You'll probably find that some SVG images crash
561 Emacs. Problems have been observed in some images that contain
562 text, they seem to be a problem in the Windows port of Pango, or
563 maybe a problem with the way Cairo or librsvg is using it that
564 doesn't show up on other platforms.
567 This file is part of GNU Emacs.
569 GNU Emacs is free software: you can redistribute it and/or modify
570 it under the terms of the GNU General Public License as published by
571 the Free Software Foundation, either version 3 of the License, or
572 (at your option) any later version.
574 GNU Emacs is distributed in the hope that it will be useful,
575 but WITHOUT ANY WARRANTY; without even the implied warranty of
576 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
577 GNU General Public License for more details.
579 You should have received a copy of the GNU General Public License
580 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.