Allow packages to change the hl-line overlay priority
[emacs.git] / nt / INSTALL.W64
blob8f0d0c9528faa632e84dcc8b7e91abb2299c09cd
1           Building and Installing Emacs on 64-bit MS-Windows
2                       using MSYS2 and MinGW-w64
4   Copyright (c) 2015-2021 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.
14 * Requirements
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 https://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)
30 from
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
41 opened.
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-jansson \
56   mingw-w64-x86_64-libxml2 \
57   mingw-w64-x86_64-gnutls \
58   mingw-w64-x86_64-zlib \
59   mingw-w64-x86_64-harfbuzz
61 The packages include the base developer tools (autoconf, grep, make, etc.),
62 the compiler toolchain (gcc, gdb, etc.), several image libraries, an XML
63 library, the GnuTLS (transport layer security) library, zlib for
64 decompressing text, and HarfBuzz for use as the shaping engine.  Only the
65 first three packages are required (base-devel,  toolchain, xpm-nox); the
66 rest are optional.  You can select only part of the libraries if you don't
67 need them all.
69 You now have a complete build environment for Emacs.
71 * Install Git (optional) and disable autocrlf
73 If you're going to be building the development version of Emacs from the Git
74 repository, and you don't already have Git on your system, you can install it
75 in your MSYS2 environment with:
77   pacman -S git
79 The autocrlf feature of Git may interfere with the configure file, so it is
80 best to disable this feature by running the command:
82   git config core.autocrlf false
84 * Get the Emacs source code
86 Now you can either get an existing release version of the Emacs source code
87 from the GNU ftp site, or get the more current version and history from the
88 Git repository.
90 You can always find the most recent information on these sources from the GNU
91 Savannah Emacs site, https://savannah.gnu.org/projects/emacs.
93 ** From the FTP site
95 The Emacs ftp site is located at https://ftp.gnu.org/gnu/emacs/ - download the
96 version you want to build and put the file into a location like C:\emacs\,
97 then uncompress it with tar.  This will put the Emacs source into a folder like
98 C:\emacs\emacs-24.5:
100   cd /c/emacs
101   tar xJf emacs-24.5.tar.xz
103 ** From the Git repository
105 To download the Git repository, do something like the following -- this will
106 put the Emacs source into C:\emacs\emacs-26:
108   mkdir /c/emacs
109   cd /c/emacs
110   git clone git://git.sv.gnu.org/emacs.git emacs-26
112 (We recommend using the command shown on Savannah Emacs project page.)
114 * Build Emacs
116 Now you're ready to build and install Emacs with autogen, configure, make,
117 and make install.
119 First we need to switch to the MinGW-w64 environment.  Exit the MSYS2 BASH
120 console and run mingw64.exe in the C:\msys64 folder, then cd back to
121 your Emacs source directory, e.g.:
123   cd /c/emacs/emacs-26
125 ** Run autogen
127 If you are building the development sources, run autogen to generate the
128 configure script (note: this step is not necessary if you are using a
129 release source tarball, as the configure file is included):
131   ./autogen.sh
133 ** Run configure
135 Now you can run configure, which will build the various Makefiles -- note
136 that the example given here is just a simple one - for more information
137 on the options available please see the INSTALL file in this directory.
139 The '--prefix' option specifies a location for the resulting binary files,
140 which 'make install' will use - in this example we set it to C:\emacs\emacs-26.
141 If a prefix is not specified the files will be put in the standard Unix
142 directories located in your C:\msys64 directory, but this is not recommended.
144 Note also that we need to disable D-Bus because Emacs does not yet
145 support them on Windows.
147   ./configure --prefix=/c/emacs/emacs-26 --without-dbus
149 ** Run make
151 This will compile Emacs and build the executables, putting them in the src
152 directory:
154   make
156 To speed up the process, you can try running
158   make -jN
160 where N is the number of cores in your system -- if your MSYS2 make supports
161 parallel execution it will run significantly faster.
163 ** Run make install
165 Now you can run "make install", which will copy the executable and
166 other files to the location specified in the configure step. This will
167 create the bin, libexec, share, and var directories:
169   make install
171 You can also say
173   make install prefix=/c/somewhere
175 to install them somewhere else.
177 * Test Emacs
179 To test it out, run
181   ./bin/runemacs.exe -Q
183 and if all went well, you will have a new 64-bit version of Emacs.
185 When running Emacs from outside the mingw64 shell, you will need to
186 add c:\msys64\mingw64\bin to your Windows PATH, or copy the needed
187 DLLs into Emacs' bin/ directory.  Otherwise features such as TLS which
188 depend on those DLLs will be missing.
190 You can do this through Control Panel / System and Security / System /
191 Advanced system settings / Environment Variables / Edit path.
193 * Make a shortcut
195 To make a shortcut to run the new Emacs, right click on the location where you
196 want to put it, e.g. the Desktop, select New / Shortcut, then select
197 runemacs.exe in the bin folder of the new Emacs, and give it a name.
199 You can set any command line options by right clicking on the resulting
200 shortcut, select Properties, then add any options to the Target command,
201 e.g. --debug-init.
203 * Troubleshooting
205 ** Missing mingw64.exe launcher
207 Older versions of Msys2 may lack the mingw64.exe launcher program.  If
208 you have them, running mingw64_shell.bat or "msys2_shell.cmd -mingw64"
209 should work instead.
211 Alternatively, install mingw64.exe with
213     pacman -S msys/msys2-launcher-git
215 ** Configure errors
217 *** Check that mingw64 gcc is accessible
219 Errors like
221     configure: error: Emacs does not support 'x86_64-pc-msys' systems.
225     checking the compiler's target... configure: error: Impossible to obtain gcc compiler target.
227 indicate you didn't use the mingw64 launcher, or you didn't install
228 gcc.  It's also possible you have something in ~/.bashrc or ~/.profile
229 which modifies PATH or MSYSTEM to an unexpected value, preventing gcc
230 from being found.  At the mingw64 bash shell, running
232     gcc -v
234 should give output which includes the text
236     Target: x86_64-w64-mingw32
238 *** Check your $PKG_CONFIG_PATH
240 For a typical MSYS2 install, running
242     echo $PKG_CONFIG_PATH
244 at the mingw64 bash shell should give print a value starting with
245 '/mingw64/lib/pkgconfig'.  Incorrect values may prevent configure from
246 finding installed libraries.
248 * Credits
250 Thanks to Chris Zheng for the original build outline as used by the
251 emacsbinw64 project, located at:
253   https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/
255 * License
257 This file is part of GNU Emacs.
259 GNU Emacs is free software: you can redistribute it and/or modify
260 it under the terms of the GNU General Public License as published by
261 the Free Software Foundation, either version 3 of the License, or
262 (at your option) any later version.
264 GNU Emacs is distributed in the hope that it will be useful,
265 but WITHOUT ANY WARRANTY; without even the implied warranty of
266 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
267 GNU General Public License for more details.
269 You should have received a copy of the GNU General Public License
270 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.