1 Building and Installing Emacs on 64-bit MS-Windows
2 using MSYS2 and MinGW-w64
4 Copyright (c) 2015-2018 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 ** Download and install the necessary packages
40 Run c:/msys64/msys2.exe in your MSYS2 directory and you will see a BASH window
43 In the BASH prompt, use the following command to install the necessary
44 packages (you can copy and paste it into the shell with Shift + Insert):
46 pacman -S --needed base-devel \
47 mingw-w64-x86_64-toolchain \
48 mingw-w64-x86_64-xpm-nox \
49 mingw-w64-x86_64-libtiff \
50 mingw-w64-x86_64-giflib \
51 mingw-w64-x86_64-libpng \
52 mingw-w64-x86_64-libjpeg-turbo \
53 mingw-w64-x86_64-librsvg \
54 mingw-w64-x86_64-lcms2 \
55 mingw-w64-x86_64-libxml2 \
56 mingw-w64-x86_64-gnutls \
59 The packages include the base developer tools (autoconf, grep, make, etc.),
60 the compiler toolchain (gcc, gdb, etc.), several image libraries, an XML
61 library, the GnuTLS (transport layer security) library, and zlib for
62 decompressing text. Only the first three packages are required (base-devel,
63 toolchain, xpm-nox); the rest are optional. You can select only part of the
64 libraries if you don't need them all.
66 You now have a complete build environment for Emacs.
68 * Install Git (optional) and disable autocrlf
70 If you're going to be building the development version of Emacs from the Git
71 repository, and you don't already have Git on your system, you can install it
72 in your MSYS2 environment with:
76 The autocrlf feature of Git may interfere with the configure file, so it is
77 best to disable this feature by running the command:
79 git config core.autocrlf false
81 * Get the Emacs source code
83 Now you can either get an existing release version of the Emacs source code
84 from the GNU ftp site, or get the more current version and history from the
87 You can always find the most recent information on these sources from the GNU
88 Savannah Emacs site, https://savannah.gnu.org/projects/emacs.
92 The Emacs ftp site is located at https://ftp.gnu.org/gnu/emacs/ - download the
93 version you want to build and put the file into a location like C:\emacs\,
94 then uncompress it with tar. This will put the Emacs source into a folder like
98 tar xJf emacs-24.5.tar.xz
100 ** From the Git repository
102 To download the Git repository, do something like the following -- this will
103 put the Emacs source into C:\emacs\emacs-26:
107 git clone git://git.sv.gnu.org/emacs.git emacs-26
109 (We recommend using the command shown on Savannah Emacs project page.)
113 Now you're ready to build and install Emacs with autogen, configure, make,
116 First we need to switch to the MinGW-w64 environment. Exit the MSYS2 BASH
117 console and run mingw64.exe in the C:\msys64 folder, then cd back to
118 your Emacs source directory, e.g.:
124 If you are building the development sources, run autogen to generate the
125 configure script (note: this step is not necessary if you are using a
126 release source tarball, as the configure file is included):
132 Now you can run configure, which will build the various Makefiles -- note
133 that the example given here is just a simple one - for more information
134 on the options available please see the INSTALL file in this directory.
136 The '--prefix' option specifies a location for the resulting binary files,
137 which 'make install' will use - in this example we set it to C:\emacs\emacs-26.
138 If a prefix is not specified the files will be put in the standard Unix
139 directories located in your C:\msys64 directory, but this is not recommended.
141 Note also that we need to disable Imagemagick and D-Bus because Emacs
142 does not yet support them on Windows.
144 ./configure --prefix=/c/emacs/emacs-26 --without-imagemagick --without-dbus
148 This will compile Emacs and build the executables, putting them in the src
153 To speed up the process, you can try running
157 where N is the number of cores in your system -- if your MSYS2 make supports
158 parallel execution it will run significantly faster.
162 Now you can run "make install", which will copy the executable and
163 other files to the location specified in the configure step. This will
164 create the bin, libexec, share, and var directories:
170 make install prefix=/c/somewhere
172 to install them somewhere else.
178 ./bin/runemacs.exe -Q
180 and if all went well, you will have a new 64-bit version of Emacs.
182 When running Emacs from outside the mingw64 shell, you will need to
183 add c:\msys64\mingw64\bin to your Windows PATH, or copy the needed
184 DLLs into Emacs' bin/ directory. Otherwise features such as TLS which
185 depend on those DLLs will be missing.
187 You can do this through Control Panel / System and Security / System /
188 Advanced system settings / Environment Variables / Edit path.
192 To make a shortcut to run the new Emacs, right click on the location where you
193 want to put it, e.g. the Desktop, select New / Shortcut, then select
194 runemacs.exe in the bin folder of the new Emacs, and give it a name.
196 You can set any command line options by right clicking on the resulting
197 shortcut, select Properties, then add any options to the Target command,
202 ** Missing mingw64.exe launcher
204 Older versions of Msys2 may lack the mingw64.exe launcher program. If
205 you have them, running mingw64_shell.bat or "msys2_shell.cmd -mingw64"
208 Alternatively, install mingw64.exe with
210 pacman -S msys/msys2-launcher-git
214 *** Check that mingw64 gcc is accessible
218 configure: error: Emacs does not support 'x86_64-pc-msys' systems.
222 checking the compiler's target... configure: error: Impossible to obtain gcc compiler target.
224 indicate you didn't use the mingw64 launcher, or you didn't install
225 gcc. It's also possible you have something in ~/.bashrc or ~/.profile
226 which modifies PATH or MSYSTEM to an unexpected value, preventing gcc
227 from being found. At the mingw64 bash shell, running
231 should give output which includes the text
233 Target: x86_64-w64-mingw32
235 *** Check your $PKG_CONFIG_PATH
237 For a typical MSYS2 install, running
239 echo $PKG_CONFIG_PATH
241 at the mingw64 bash shell should give print a value starting with
242 '/mingw64/lib/pkgconfig'. Incorrect values may prevent configure from
243 finding installed libraries.
247 Thanks to Chris Zheng for the original build outline as used by the
248 emacsbinw64 project, located at:
250 https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/
254 This file is part of GNU Emacs.
256 GNU Emacs is free software: you can redistribute it and/or modify
257 it under the terms of the GNU General Public License as published by
258 the Free Software Foundation, either version 3 of the License, or
259 (at your option) any later version.
261 GNU Emacs is distributed in the hope that it will be useful,
262 but WITHOUT ANY WARRANTY; without even the implied warranty of
263 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264 GNU General Public License for more details.
266 You should have received a copy of the GNU General Public License
267 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.