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