Prefer HTTPS to HTTP for gnu.org
[emacs.git] / nt / INSTALL.W64
blob841660bf0f9c95243d3ee88f144848998238e79d
1           Building and Installing Emacs on 64-bit MS-Windows
2                       using MSYS2 and MinGW-w64
4   Copyright (c) 2015-2017 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 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)
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 Then you'll need to add the following directories to your Windows PATH
39 environment variable:
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
53 opened.
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-liblcms2 \
67   mingw-w64-x86_64-libxml2 \
68   mingw-w64-x86_64-gnutls \
69   mingw-w64-x86_64-zlib
71 The packages include the base developer tools (autoconf, grep, make, etc.),
72 the compiler toolchain (gcc, gdb, etc.), several image libraries, an XML
73 library, the GnuTLS (transport layer security) library, and zlib for
74 decompressing text.  Only the first three packages are required (base-devel,
75 toolchain, xpm-nox); the rest are optional.  You can select only part of the
76 libraries if you don't need them all.
78 You now have a complete build environment for Emacs.
80 * Install Git (optional) and disable autocrlf
82 If you're going to be building the development version of Emacs from the Git
83 repository, and you don't already have Git on your system, you can install it
84 in your MSYS2 environment with:
86   pacman -S git
88 The autocrlf feature of Git may interfere with the configure file, so it is
89 best to disable this feature by running the command:
91   git config core.autocrlf false
93 * Get the Emacs source code
95 Now you can either get an existing release version of the Emacs source code
96 from the GNU ftp site, or get the more current version and history from the
97 Git repository.
99 You can always find the most recent information on these sources from the GNU
100 Savannah Emacs site, https://savannah.gnu.org/projects/emacs.
102 ** From the FTP site
104 The Emacs ftp site is located at https://ftp.gnu.org/gnu/emacs/ - download the
105 version you want to build and put the file into a location like C:\emacs\,
106 then uncompress it with tar.  This will put the Emacs source into a folder like
107 C:\emacs\emacs-24.5:
109   cd /c/emacs
110   tar xJf emacs-24.5.tar.xz
112 ** From the Git repository
114 To download the Git repository, do something like the following -- this will
115 put the Emacs source into C:\emacs\emacs-25:
117   mkdir /c/emacs
118   cd /c/emacs
119   git clone git://git.sv.gnu.org/emacs.git emacs-25
121 (We recommend using the command shown on Savannah Emacs project page.)
123 * Build Emacs
125 Now you're ready to build and install Emacs with autogen, configure, make,
126 and make install.
128 First we need to switch to the MinGW-w64 environment.  Exit the MSYS2 BASH
129 console and run mingw64_shell.bat in the C:\msys64 folder, then cd back to
130 your Emacs source directory, e.g.:
132   cd /c/emacs/emacs-25
134 ** Run autogen
136 If you are building the development sources, run autogen to generate the
137 configure script (note: this step is not necessary if you are using a
138 release source tarball, as the configure file is included):
140   ./autogen.sh
142 ** Run configure
144 Now you can run configure, which will build the various Makefiles -- note
145 that the example given here is just a simple one - for more information
146 on the options available please see the INSTALL file in this directory.
148 The '--prefix' option specifies a location for the resulting binary files,
149 which 'make install' will use - in this example we set it to C:\emacs\emacs-25.
150 If a prefix is not specified the files will be put in the standard Unix
151 directories located in your C:\msys64 directory, but this is not recommended.
153 Note also that we need to disable Imagemagick because Emacs does not yet
154 support it on Windows.
156   PKG_CONFIG_PATH=/mingw64/lib/pkgconfig \
157   ./configure --prefix=/c/emacs/emacs-25 --without-imagemagick
159 ** Run make
161 This will compile Emacs and build the executables, putting them in the src
162 directory:
164   make
166 To speed up the process, you can try running
168   make -jN
170 where N is the number of cores in your system -- if your MSYS2 make supports
171 parallel execution it will run significantly faster.
173 ** Run make install
175 Now you can run "make install", which will copy the executable and
176 other files to the location specified in the configure step. This will
177 create the bin, libexec, share, and var directories:
179   make install
181 You can also say
183   make install prefix=/c/somewhere
185 to install them somewhere else.
187 * Test Emacs
189 To test it out, run
191   ./bin/runemacs.exe -Q
193 and if all went well, you will have a new 64-bit version of Emacs.
195 * Make a shortcut
197 To make a shortcut to run the new Emacs, right click on the location where you
198 want to put it, e.g. the Desktop, select New / Shortcut, then select
199 runemacs.exe in the bin folder of the new Emacs, and give it a name.
201 You can set any command line options by right clicking on the resulting
202 shortcut, select Properties, then add any options to the Target command,
203 e.g. --debug-init.
205 * Credits
207 Thanks to Chris Zheng for the original build outline as used by the
208 emacsbinw64 project, located at:
210   https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/
212 * License
214 This file is part of GNU Emacs.
216 GNU Emacs is free software: you can redistribute it and/or modify
217 it under the terms of the GNU General Public License as published by
218 the Free Software Foundation, either version 3 of the License, or
219 (at your option) any later version.
221 GNU Emacs is distributed in the hope that it will be useful,
222 but WITHOUT ANY WARRANTY; without even the implied warranty of
223 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
224 GNU General Public License for more details.
226 You should have received a copy of the GNU General Public License
227 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.