Thanks for the feedback - the updated file is included at the end and at
https://gist.github.com/bburns/43c9f170361aecee3b71 - Chris added a
few comments there.
>> I tried running configure without the '--host=x86_64-w64-mingw32' etc switches
>> but got an error:
>> configure: error: Emacs does not support 'x86_64-pc-msys' systems.
This turned out to be due to not being in the right environment - I added the
step to switch to the MinGW-w64 environment and now it works without specifying
the --host, etc.
> Sorry, I don't understand: this _is_ INSTALL, isn't it? And the
> current INSTALL does include a couple of examples. What am I missing?
At the moment, this is a separate file - e.g. it could be nt/INSTALL64, though
if we wanted we could merge them.
When I tried using the nt/INSTALL instructions last year I was mostly confused
about the --prefix option - I didn't understand what was meant by build inside
or outside the source tree, and the example given, /d/usr, was a bit foreign to
me as a place to store programs, so Chris's example was easier to follow. I
tried to keep these instructions simple also, but referred the user to the
nt/INSTALL file for more information in a couple of places.
>> I think this was in part because MSYS2 doesn't add its folders to the PATH, and
>> if you use the PATH variable there might be both 32-bit and 64-bit DLLs on it,
> But that's a problem MSYS2 and MinGW64 should have solved already,
> right? IOW, it's not something specific to Emacs.
Okay, straightened that out a bit, now it says
Adding these directories to your PATH tells Emacs where to find the DLLs it
needs to run, and some optional commands like grep and find. These commands
will also be available at the Windows console.
> I indeed think that the instructions should tell how to create a
> desktop shortcut for running Emacs.
> I would suggest removing this time information
Okay, added a section for making a shortcut, and removed the time info.
> I guess you didn't use "make -j8" or some such.
That's a good option to include - I added it to the make section.
Thanks again for your help -
Brian
------------
Building and Installing Emacs on 64-bit MS-Windows
using MSYS2 and MinGW-w64
Copyright (c) 2015 Free Software Foundation, Inc.
See the end of the file for license conditions.
This document describes how to compile a 64-bit GNU Emacs using MSYS2 and
MinGW-w64. For more detailed information on the build process, and instructions
for building a 32-bit Emacs using MSYS and MinGW, see the INSTALL document in
this directory.
Do not use this recipe with Cygwin. For building on Cygwin, use the normal
installation instructions in ../INSTALL.
* Requirements
The total space required is 3GB: 1.8GB for MSYS2 / MinGW-w64 and 1.2GB for
Emacs with the full repository, or less if you're using a release tarball.
* Set up the MinGW-w64 / MSYS2 build environment
MinGW-w64 provides a complete runtime for projects built with gcc for 64-bit
Windows - it's located at
http://mingw-w64.org/.
MSYS2 is a Cygwin-derived software distribution for Windows which provides
build tools for MinGW-w64 - see
http://msys2.github.io/.
** Download and install MinGW-w64 and MSYS2
You can download the x86_64 version of MSYS2 (i.e. msys2-x86_64-<date>.exe)
from
https://sourceforge.net/projects/msys2/files/Base/x86_64 Run this file to install MSYS2 in your preferred directory, e.g. the default
C:\msys64 - this will install MinGW-w64 also. Note that directory names
containing spaces may cause problems.
Then you'll need to add the following directories to your Windows PATH
environment variable -
c:\msys64\usr\bin;c:\msys64\mingw64\bin
you can do this through Control Panel / System and Security / System /
Advanced system settings / Environment Variables / Edit path.
Adding these directories to your PATH tells Emacs where to find the DLLs it
needs to run, and some optional commands like grep and find. These commands
will also be available at the Windows console.
** Download and install the necessary packages
Run msys2_shell.bat in your MSYS2 directory and you will see a BASH window
opened.
In the BASH prompt, use the following command to install the necessary
packages (you can copy and paste it into the shell with Shift + Insert):
pacman -S base-devel \
mingw-w64-x86_64-toolchain \
mingw-w64-x86_64-xpm-nox \
mingw-w64-x86_64-libtiff \
mingw-w64-x86_64-giflib \
mingw-w64-x86_64-libpng \
mingw-w64-x86_64-libjpeg-turbo \
mingw-w64-x86_64-librsvg \
mingw-w64-x86_64-libxml2 \
mingw-w64-x86_64-gnutls
The packages include the base developer tools (autoconf, automake, grep, make,
etc.), the compiler toolchain (gcc, gdb, etc.), several image libraries, an
xml library, and the GnuTLS (transport layer security) library. Only the
first three packages are required (base-devel, toolchain, xpm-nox) - the rest
are optional.
You now have a complete build environment for Emacs.
* Install git (optional) and disable autocrlf
If you're going to be building the development version of Emacs from the git
repository, and you don't already have git on your system, you can install it
in your MSYS2 environment with:
pacman -S git
The autocrlf feature of Git may interfere with the configure file, so it is
best to disable this feature by running the command:
git config core.autocrlf false
* Get the Emacs source code
Now you can either get an existing release version of the Emacs source code
from the GNU ftp site, or get the more current version and history from the
git repository.
You can always find the most recent information on these sources from the GNU
Savannah Emacs site,
https://savannah.gnu.org/projects/emacs.
** From the FTP site
The Emacs ftp site is located at
http://ftp.gnu.org/gnu/emacs/ - download the
version you want to build and put the file into a location like C:\emacs\,
then uncompress it with tar. This will put the Emacs source into a folder like
C:\emacs\emacs-24.5:
cd /c/emacs
tar xf emacs-24.5.tar.xz
** From the git repository
To download the git repository, do something like the following - this will
put the Emacs source into C:\emacs\emacs-25:
mkdir /c/emacs
cd /c/emacs
git clone git://
git.sv.gnu.org/emacs.git emacs-25
* Build Emacs
Now you're ready to build and install Emacs with autogen, configure, make,
and make install.
First we need to switch to the MinGW-w64 environment - exit the MSYS2 BASH
console and run mingw64_shell.bat in the C:\msys64 folder, then cd back to
your Emacs source directory, e.g.:
cd /c/emacs/emacs-25
** Run autogen
Run autogen to generate the configure script (note: this step is not necessary
if you are using a release source tarball, as the configure file is included):
./autogen.sh
** Run configure
Now you can run configure, which will build the various Makefiles - note that
the example given here is just a simple one - for more information on the
options available please see the nt/INSTALL file.
The --prefix option specifies a location for the resulting binary files, which
'make install' will use - in this example we set it to C:\emacs\emacs-25. If a
prefix is not specified the files will be put in the standard Unix directories
located in your C:\msys64 directory, but this is not recommended.
Note also that we need to disable Imagemagick because Emacs does not yet
support it on Windows.
PKG_CONFIG_PATH=/mingw64/lib/pkgconfig \
./configure \
--prefix=/c/emacs/emacs-25 \
--without-imagemagick
** Run make
This will compile Emacs and build the executables, putting them in the src
directory:
make
To speed up the process, you can try running
make -jN
where N is the number of cores in your system - if your MSYS2 make supports
parallel execution it will run significantly faster.
** Run make install
Now you can run make install, which will copy the executable and other files
to the location specified in the configure step. This will create the bin,
libexec, share, and var directories:
make install
You can also say
make install prefix=/c/somewhere
to install them somewhere else.
* Test Emacs
To test it out, run
./bin/runemacs.exe -Q
and if all went well, you will have a new 64-bit version of Emacs.
* Make a shortcut
To make a shortcut to run the new Emacs, right click on the location where you
want to put it, e.g. the Desktop, select New / Shortcut, then select
runemacs.exe in the bin folder of the new Emacs, and give it a name.
You can set any command line options by right clicking on the resulting
shortcut, select Properties, then add any options to the Target command,
e.g. --debug-init.
* Credits
Thanks to Chris Zheng for the original build outline as used by the
emacsbinw64 project, located at:
https://sourceforge.net/p/emacsbinw64/wiki/Build%20guideline%20for%20MSYS2-MinGW-w64%20system/* License
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <
http://www.gnu.org/licenses/>.