Skip to content

Instantly share code, notes, and snippets.

@LukeDRussell
Last active May 28, 2025 11:30
Show Gist options
  • Save LukeDRussell/7a5145e368e402772fe95f687cde4154 to your computer and use it in GitHub Desktop.
Save LukeDRussell/7a5145e368e402772fe95f687cde4154 to your computer and use it in GitHub Desktop.
Compile & install emacs on Windows

This is how I install emacs 30 on Windows 11, to get native compilation support.

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 -Syi

Restart the session if required.

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

Clone emacs

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

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

(Optional) Checkout stable branch

git checkout emacs-30

You may need to --force the checkout.

Compile

Autogen

./autogen.sh

Configure

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

Make & Install

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

make -j 16 bootstrap
make install

(First time only) Setup Windows envars and shortcuts

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 a shortcut

Create a shortcut to "C:\emacs\bin\runemacs.exe", probably on ~\Desktop. Change the shortcut's Start in: value to your home folder i.e. C:\Users\Luke\

Create symlink for init.el

In powershell or pwsh:

cd ~/.emacs.d/
New-Item -ItemType SymbolicLink -Path init.el -Target C:\Users\Luke\Repos\dotfiles\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.

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