[Tex/LaTex] Links to glossary items broken

glossarieshyperrefincompatibility

I'm currently writing a large document, and I have two glossaries, one for acronyms, and one for a normal glossary. I have hyperref setup so that the glossary entries in the main text have links to the glossary items. At least that's the plan. Unfortunately, this does not work, and all the links point to the first page of the document.

Here is my MWE:

\documentclass[a4paper]{memoir}
\usepackage[acronym,toc]{glossaries}
\usepackage{hyperref}
\makeglossaries
\pagestyle{ruled}
\newglossaryentry{UML}{name={UML},description={definition}}
\newacronym{XML}{XML}{Extensible Markup Language}
\begin{document}
\chapter{Intro}
\gls{XML}
\gls{UML}
\printglossaries
\end{document}

For building with latexmk, I'm using this .latexmkrc:

add_cus_dep('glo', 'gls', 0, 'makeglossaries');
sub makeglossaries {
    system("makeglossaries '$_[0]'");
}

pdflatex outputs these warnings:

pdfTeX warning (dest): name{glo:UML} has been referenced but does not exist, replaced by a fixed one
pdfTeX warning (dest): name{glo:XML} has been referenced but does not exist, replaced by a fixed one

I'm not sure where this glo: prefix in the warning comes from, maybe that's the problem?

And no, this is not a duplicate of How to get correct glossary links with frontmatter pages?. The back links, from glossary items to the occurrence in the text, work for me.

Best Answer

Contrary to most other packages, glossaries must be loaded after hyperref. This fact is highlighted at p. 2 of the glossaries beginners guide. See Which packages should be loaded after hyperref instead of before? for a list of the most important "hyperref exceptions".

Related Question