15

I installed binaries of Emacs 24.4 for Windows and want to install the support libraries described in the Emacs for Windows README. The latest precompiled libraries are available from the ezwinports project, but installing them is a little time-consuming. I have to select all of the libraries mentioned in Emacs's README, scan the ezwinports README for any further prerequisites, and download each one of the zip archives. Then unpack them, move them to a permanent location, and add the individual directories to my PATH variable. There are duplicate files within these archives, so I am wary of unpacking them all to the same directory without checking that they are identical.

Is there an automated way to do this?

  • As far as I could tell the binary downloads contain all the pre-requisites so even though they're listed in the readme you don't need to bother downloading them separately. That's why you have duplicate files in the different packages. – Alan Third May 7 '15 at 8:41
10

Beginning with Emacs 25, the Emacs Windows download directory now includes a deps package that includes all the dependencies for a particular architecture. For example, for x86_64, use emacs-25-x86_64-deps.zip.

I use the following script to automatically install Emacs. It should work for WSL or Cygwin. It must be run under elevation and already have run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned in PowerShell at some point.

#!/usr/bin/env bash

set -o nounset -o pipefail -o errexit

emacs_major=26
emacs_minor=1
emacs_ver="$emacs_major.$emacs_minor"
arch="x86_64"
emacs_url_root="https://ftpmirror.gnu.org/emacs/windows/emacs-$emacs_major"

emacs_deps_zip="emacs-$emacs_major-$arch-deps.zip"
emacs_zip="emacs-$emacs_ver-$arch.zip"

if [[ "$(uname -r)" == *Microsoft ]]; then
    programfiles="$(bin/wslpath "%ProgramFiles%")"
    programfilesx86="$(bin/wslpath "%ProgramFiles(x86)%")"
    allusersprofile="$(bin/wslpath "%AllUsersProfile%")"
    public_desktop="$(bin/wslpath "%Public%\\Desktop")"
    desktop="$(bin/wslpath "%UserProfile%\\Desktop")"
else
    CSIDL_PROGRAM_FILES=38
    CSIDL_PROGRAM_FILESX86=42
    CSIDL_COMMON_APPDATA=35
    CSIDL_COMMON_DESKTOPDIRECTORY=25
    CSIDL_DESKTOP=0

    programfiles="$(cygpath -F "$CSIDL_PROGRAM_FILES")"
    programfilesx86="$(cygpath -F "$CSIDL_PROGRAM_FILESX86")"
    allusersprofile="$(cygpath -F "$CSIDL_COMMON_APPDATA")"
    public_desktop="$(cygpath -F "$CSIDL_COMMON_DESKTOPDIRECTORY")"
    desktop="$(cygpath -F "$CSIDL_DESKTOP")"
fi

emacs_root="$programfiles/Emacs"

old_tmpdir="${TMPDIR:-}"
TMPDIR="$(mktemp -dt install-windows-pkgs.XXXXXXXXXX)"
export TMPDIR

on_exit () {
    rm -rf "$TMPDIR"
}

trap on_exit EXIT

unzip_dest () {
    local zip="$1"
    local dest="$2"

    if [[ ! -d "$dest" ]]; then
        if ! mkdir -p "$dest"; then
            result="$?"
            echo "Can't create '$dest'. Try running under elevation" >&2
            exit "$result"
        fi

        unzip -n "$zip" -d "$dest"
    fi
}

install_emacs_pkg () {
    local zip="$1"
    local dest="$2"

    # XXX: move to tmp
    if [[ ! -d "$dest" ]]; then
        wget --directory-prefix "$TMPDIR" "$emacs_url_root/$zip"
        unzip_dest "$TMPDIR/$zip" "$dest"
    fi
}

on_exit
trap EXIT
TMPDIR="$old_tmpdir"

# XXX: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
# XXX: sticking cmd.exe /c start before this causes all nature of space-quoting problems
powershell.exe windows\\add_path.ps1 "%ProgramFiles%\\Emacs\\emacs-$emacs_ver\\bin" "%ProgramFiles%\\Emacs\\emacs-$emacs_major-deps\\bin"

# XXX: would be nice to pin runemacs.exe to taskbar, but the need to edit
# that is probably best seen as Emacs bug/flaw
5

This isn't a fully-automated solution, but it's part of the way there. As far as I can tell, the current set of support libraries and their prerequisites is:

  • libpng-1.6.12
  • cairo-1.12.16
  • gdk-pixbuf-2.30.2
  • giflib-5.1.0
  • glib-2.38.2
  • gnutls-3.0.9
  • jpeg-v9a
  • libcroco-0.6.8
  • libffi-3.0.13
  • librsvg-2.40.1-2
  • libxml2-2.7.8
  • lzo-2.06
  • pango-1.36.1-2
  • pixman-0.32.4
  • tiff-4.0.3
  • zlib-1.2.8-2

Download all of these from the ezwinports files area to a staging directory. Then use unp to unpack each of these to directories of their own. Use the rename command in Cygwin to eliminate any -w32-bin suffixes.

rename -- -w32-bin "" *-w32-bin

Use a command like the following to get the list of directories you need to add to your PATH:

command ls -1 | perl -pe 's/^/C:\\Program Files (x86)\\/; s/\n/\\bin;/'

You can then move all of these to a location like C:\Program Files (x86).

  • 2
    Since the support libraries are likely to change, I'm reluctant to spend much time trying to clean up or automate the whole thing. Unp and rename aren't really necessary, as you can simply unzip these files into the desired location. But I had them around so it was easier to use them. – Michael Hoffman Nov 25 '14 at 13:59
4

I know this is an old question, but for if someone stumbles upon this: Try emacsbinw64 or emacsbin. They contain all required dlls and you don't have to resolve dependencies manually.

  • Note that appears to have stopped being updated. – NetMage Mar 19 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.