Skip to content

Instantly share code, notes, and snippets.

@LukeDRussell
Last active June 29, 2026 05:02
Show Gist options
  • Select an option

  • Save LukeDRussell/7a5145e368e402772fe95f687cde4154 to your computer and use it in GitHub Desktop.

Select an option

Save LukeDRussell/7a5145e368e402772fe95f687cde4154 to your computer and use it in GitHub Desktop.
Compile, install & setup emacs on Windows

This is how I install emacs 31 on Windows 11, to get native compilation support, requiring MSYS2 to remain installed.

Prerequisites

Install msys2

winget install msys2.msys2

Add a profile for mingw64 in Windows Terminal

    "profiles": 
    {
        "list": 
        [
            {
                "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
                "guid": "{05becdfa-31e7-4900-ae5d-818333d164f6}",
                "hidden": false,
                "icon": "C:/msys64/mingw64.ico",
                "name": "MINGW64 / MSYS2",
                "startingDirectory": "%USERPROFILE%"
            },
        ]
    }

Update pacman

In a new mingw64 session

pacman -Suy

If asked, agree to update. Then close session, and re-open.

pacman -Su

Install dependencies with pacman

pacman -S --needed \
  base-devel \
  autoconf \
  git \
  mingw-w64-x86_64-toolchain \
  mingw-w64-x86_64-xpm-nox \
  mingw-w64-x86_64-gmp \
  mingw-w64-x86_64-gnutls \
  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-libwebp \
  mingw-w64-x86_64-lcms2 \
  mingw-w64-x86_64-libxml2 \
  mingw-w64-x86_64-zlib \
  mingw-w64-x86_64-harfbuzz \
  mingw-w64-x86_64-libgccjit \
  mingw-w64-x86_64-sqlite3 \
  mingw-w64-x86_64-libtree-sitter

Get source code

Use github, it's a lot faster than Savanah.

git config core.autocrlf false
cd Repos
git clone https://github.com/emacs-mirror/emacs 
cd emacs
git checkout emacs-31

Compile

Autogen

./autogen.sh

Configure

./configure 
    --without-dbus \
    --without-gconf \
    --without-gsettings \
    --without-pop \
    --without-compress-install \
    --with-gnutls \
    --with-modules \
    --with-wide-int \
    --prefix=/c/emacs/emacs-31

Make & Install

Change 12 to no more than 3/4 of your available CPU cores.

make -j 12 bootstrap
make install

Troubleshooting

Try

make clean, make extraclean, and git clean -fdx. Then repeat previous step.

Setup & Config

Modify envars

  1. Add C:\msys64\mingw64\bin\ to PATH so the msys2 DLLs are available to the binaries.
  2. Set HOME to C:\Users\Luke

Create shortcuts

  1. To "C:\emacs\emacs-31\bin\runemacs.exe --daemon called Emacs 31 Daemon at C:\Users\luke\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Start-up. Set Start in: value to your home folder i.e. C:\Users\luke\
  2. To "C:\emacs\emacs-31\bin\emacsclientw.exe" called Emacs 31 Client at C:\Users\luke\AppData\Roaming\Microsoft\Windows\Start Menu\Programs. Set the target to C:\emacs\emacs-31\bin\emacsclientw.exe -n -c -a "C:\emacs\emacs-31\bin\runemacs.exe"
  3. To "C:\emacs\emacs-31\bin\emacsclientw.exe" called Emacs 31 at C:\Users\luke\AppData\Roaming\Microsoft\Windows\Start Menu\Programs.

Base / Starter Emacs config

I'm using minimal-emacs

cd ~
git clone --depth 1 https://github.com/jamescherti/minimal-emacs.d .emacs.d
cd .emacs.d

Create symlink for my config files

In powershell or pwsh:

cd ~/.emacs.d/
New-Item -ItemType SymbolicLink -Path pre-early-init.el -Target C:\Users\Luke\Repos\dotfiles\pre-early-init.el
New-Item -ItemType SymbolicLink -Path post-early-init.el -Target C:\Users\Luke\Repos\dotfiles\post-early-init.el
New-Item -ItemType SymbolicLink -Path pre-init.el -Target C:\Users\Luke\Repos\dotfiles\pre-init.el
New-Item -ItemType SymbolicLink -Path post-init.el -Target C:\Users\Luke\Repos\dotfiles\post-init.el

Validate

Use the shortcut to start emacs, so that open file/folder dialogs start at ~

Check native compilation is available

(native-comp-available-p)

Should evaluate to t.

Optional

Diff Utils

To run diff operations in Windows emacs, install diffutils inside of mingw64

 pacman -S mingw-w64-x86_64-diffutils

org to Open Document Format

pacman -S zip unzip

Add C:\msys64\usr\bin to PATH so zip and unzip are available to Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment