- Open msys2 shell
- Get pdf-tools
git clone https://github.com/politza/pdf-tools cd pdf-tools
- 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
- Open mingw64 shell
- Compile pdf-tools
make -s
- Open emacs
- Install
M-x package-install-file RET pdf-tools-${VERSION}.tar RET
- Activate package
M-x pdf-tools-install RET
- Test
M-x pdf-info-check-epdfinfo RET
- Step 8 failed for me and it took me a while to figure out why. There were
two problems to be fixed
- 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")))
- 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)
- 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
As a little remark: Changing the
PATH
to have mingw64 at its top can mess with other things, e.g. by overriding the systems default python distribution. This is especially problematic, since on Windows, sadly, Python 3 is also calledpython.exe
, despite the convention to call itpython3
on unix systems.As I couldn't come up with how to produce a static executable (
libpoppler
denied being compiled that way with thepacman
version), I essentially chose to bundle the executable with its dependencies:pdf-tools/server
directory in the mingw64 shell../epdfinfo
).ldd epdfinfo.exe | grep dll | grep -vi '/c/Windows' | perl -pe 's/.=> (.) (.*/$1/' | xargs -I FILE cp 'FILE' -v .
which is erring on the side of caution. It will likely copy some of the dlls from the Emacs installation, but this way the executable is independent of future changes to the Emacs installation / differences on other systems.
.dll
and.exe
files to some other directory.This way a portable Windows executable should be obtained, without the risk of side-effects from changing the path.
Downside: My epdfinfo-directory has 23MB, instead of 1.2MB for the
epdfinfo.exe
alone.