Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bangedorrunt/c0c8e489f37dca7a534b9c4de1becdca to your computer and use it in GitHub Desktop.
Save bangedorrunt/c0c8e489f37dca7a534b9c4de1becdca to your computer and use it in GitHub Desktop.
Install pdf-tools on windows with msys2

Notes for compiling and setting up pdf-tools using msys2

Steps

  1. Open msys2 shell
  2. Get pdf-tools
    git clone https://github.com/politza/pdf-tools
    cd pdf-tools
        
  3. Update and install dependencies, skipping any you already have
    pacman -Syu
    pacman -S base-devel
    pacman -S mingw-w64-x86_64-toolchain
    pacman -S mingw-w64-x86_64-zlib
    pacman -S mingw-w64-x86_64-libpng
    pacman -S mingw-w64-x86_64-poppler
    pacman -S mingw-w64-x86_64-imagemagick
        
  4. Open mingw64 shell
  5. Compile pdf-tools
    make -s
        
  6. Open emacs
  7. Install
    M-x package-install-file RET pdf-tools-${VERSION}.tar RET
        
  8. Activate package
    M-x pdf-tools-install RET
        
  9. Test
    M-x pdf-info-check-epdfinfo RET
        

Problems

  1. Step 8 failed for me and it took me a while to figure out why. There were two problems to be fixed
    1. epdfinfo.exe was loading a library from git-for-windows and there was an error from this. To fix this I made sure the mingw libraries were ahead of the git-for-windows ones in my path like this
      (setenv "PATH" (concat "C:\\msys64\\mingw64\\bin;" (getenv "PATH")))
              
    2. The default encoding for newly created files was utf-8-dos, which uses line endings that epdfinfo doesn’t like. I originally had
      (prefer-coding-system 'utf-8)
              

      but needed

      (prefer-coding-system 'utf-8-unix)
              
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment