1 Building and Installing Emacs on 64-bit MS-Windows
2 using MSYS2 and MinGW-w64
4 Copyright (c) 2015-2016 Free Software Foundation, Inc.
5 See the end of the file for license conditions.
7 This document describes how to compile a 64-bit GNU Emacs using MSYS2
8 and MinGW-w64. For instructions for building a 32-bit Emacs using
9 MSYS and MinGW, see the file INSTALL in this directory.
11 Do not use this recipe with Cygwin. For building on Cygwin, use the normal
12 installation instructions in ../INSTALL.
16 The total space required is 3GB: 1.8GB for MSYS2 / MinGW-w64 and 1.2GB for
17 Emacs with the full repository, or less if you're using a release tarball.
19 * Set up the MinGW-w64 / MSYS2 build environment
21 MinGW-w64 provides a complete runtime for projects built with GCC for 64-bit
22 Windows -- it's located at http://mingw-w64.org/.
24 MSYS2 is a Cygwin-derived software distribution for Windows which provides
25 build tools for MinGW-w64 -- see http://msys2.github.io/.
27 ** Download and install MinGW-w64 and MSYS2
29 You can download the x86_64 version of MSYS2 (i.e. msys2-x86_64-<date>.exe)
32 https://sourceforge.net/projects/msys2/files/Base/x86_64
34 Run this file to install MSYS2 in your preferred directory, e.g. the default
35 C:\msys64 -- this will install MinGW-w64 also. Note that directory names
36 containing spaces may cause problems.
38 Then you'll need to add the following directories to your Windows PATH
41 c:\msys64\usr\bin;c:\msys64\mingw64\bin
43 you can do this through Control Panel / System and Security / System /
44 Advanced system settings / Environment Variables / Edit path.
46 Adding these directories to your PATH tells Emacs where to find the DLLs it
47 needs to run, and some optional commands like grep and find. These commands
48 will also be available at the Windows console.
50 ** Download and install the necessary packages
52 Run msys2_shell.bat in your MSYS2 directory and you will see a BASH window
55 In the BASH prompt, use the following command to install the necessary
56 packages (you can copy and paste it into the shell with Shift + Insert):
58 pacman -S base-devel \
59 mingw-w64-x86_64-toolchain \
60 mingw-w64-x86_64-xpm-nox \
61 mingw-w64-x86_64-libtiff \
62 mingw-w64-x86_64-giflib \
63 mingw-w64-x86_64-libpng \
64 mingw-w64-x86_64-libjpeg-turbo \
65 mingw-w64-x86_64-librsvg \
66 mingw-w64-x86_64-libxml2 \
67 mingw-w64-x86_64-gnutls
69 The packages include the base developer tools (autoconf, automake, grep, make,
70 etc.), the compiler toolchain (gcc, gdb, etc.), several image libraries, an
71 XML library, and the GnuTLS (transport layer security) library. Only the
72 first three packages are required (base-devel, toolchain, xpm-nox); the rest
75 You now have a complete build environment for Emacs.
77 * Install Git (optional) and disable autocrlf
79 If you're going to be building the development version of Emacs from the Git
80 repository, and you don't already have Git on your system, you can install it
81 in your MSYS2 environment with:
85 The autocrlf feature of Git may interfere with the configure file, so it is
86 best to disable this feature by running the command:
88 git config core.autocrlf false
90 * Get the Emacs source code
92 Now you can either get an existing release version of the Emacs source code
93 from the GNU ftp site, or get the more current version and history from the
96 You can always find the most recent information on these sources from the GNU
97 Savannah Emacs site, https://savannah.gnu.org/projects/emacs.
101 The Emacs ftp site is located at http://ftp.gnu.org/gnu/emacs/ - download the
102 version you want to build and put the file into a location like C:\emacs\,
103 then uncompress it with tar. This will put the Emacs source into a folder like
107 tar xJf emacs-24.5.tar.xz
109 ** From the Git repository
111 To download the Git repository, do something like the following -- this will
112 put the Emacs source into C:\emacs\emacs-25:
116 git clone git://git.sv.gnu.org/emacs.git emacs-25
118 (We recommend using the command shown on Savannah Emacs project page.)
122 Now you're ready to build and install Emacs with autogen, configure, make,
125 First we need to switch to the MinGW-w64 environment. Exit the MSYS2 BASH
126 console and run mingw64_shell.bat in the C:\msys64 folder, then cd back to
127 your Emacs source directory, e.g.:
133 If you are building the development sources, run autogen to generate the
134 configure script (note: this step is not necessary if you are using a
135 release source tarball, as the configure file is included):
141 Now you can run configure, which will build the various Makefiles -- note
142 that the example given here is just a simple one - for more information
143 on the options available please see the INSTALL file in this directory.
145 The '--prefix' option specifies a location for the resulting binary files,
146 which 'make install' will use - in this example we set it to C:\emacs\emacs-25.
147 If a prefix is not specified the files will be put in the standard Unix
148 directories located in your C:\msys64 directory, but this is not recommended.
150 Note also that we need to disable Imagemagick because Emacs does not yet
151 support it on Windows.
153 PKG_CONFIG_PATH=/mingw64/lib/pkgconfig \
154 ./configure --prefix=/c/emacs/emacs-25 --without-imagemagick
158 This will compile Emacs and build the executables, putting them in the src
163 To speed up the process, you can try running
167 where N is the number of cores in your system -- if your MSYS2 make supports
168 parallel execution it will run significantly faster.
172 Now you can run "make install", which will copy the executable and
173 other files to the location specified in the configure step. This will
174 create the bin, libexec, share, and var directories:
180 make install prefix=/c/somewhere
182 to install them somewhere else.
188 ./bin/runemacs.exe -Q
190 and if all went well, you will have a new 64-bit version of Emacs.
194 To make a shortcut to run the new Emacs, right click on the location where you
195 want to put it, e.g. the Desktop, select New / Shortcut, then select
196 runemacs.exe in the bin folder of the new Emacs, and give it a name.
198 You can set any command line options by right clicking on the resulting
199 shortcut, select Properties, then add any options to the Target command,
204 Thanks to Chris Zheng for the original build outline as used by the
205 emacsbinw64 project, located at:
207 https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/
211 This file is part of GNU Emacs.
213 GNU Emacs is free software: you can redistribute it and/or modify
214 it under the terms of the GNU General Public License as published by
215 the Free Software Foundation, either version 3 of the License, or
216 (at your option) any later version.
218 GNU Emacs is distributed in the hope that it will be useful,
219 but WITHOUT ANY WARRANTY; without even the implied warranty of
220 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
221 GNU General Public License for more details.
223 You should have received a copy of the GNU General Public License
224 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.