I use the minted package for code highlight. I use its listing environment.
I also use the hyperref package to provide links all through my document: figures, tables, listings, etc.
If I import the caption package the listing links do not work properly. They take you to the begining of the document. All other links except listing links work fine.
If I do not import the caption package, all links work fine.
There is an issue opened at the project home page: Incompatibility with caption package but it seems to point to a compilation problem.
Is there any way to make the three packages work together?
EDIT:
I compiled Marco's answer and It worked like a charm so it kept me thinking about it. I have made some tests and I have come to the conclusion that it's in the order of the imports. These are my results:
\documentclass{report}
% it's all in the order of the imports
% this works
\usepackage{caption}
\usepackage{minted}
\usepackage{hyperref}
% this works
%\usepackage{minted}
%\usepackage{hyperref}
%\usepackage{caption}
% this works
%\usepackage{minted}
%\usepackage{caption}
%\usepackage{hyperref}
%this does not work
%\usepackage{hyperref}
%\usepackage{caption}
%\usepackage{minted}
%this does not work
%\usepackage{caption}
%\usepackage{hyperref}
%\usepackage{minted}
%this does not work
%\usepackage{hyperref}
%\usepackage{minted}
%\usepackage{caption}
% I'm thinking that if hyperref is imported before minted it doesn't work
%however this does work (not importing caption at all, yet hyperref is imported before minted)
%\usepackage{hyperref}
%\usepackage{minted}
\begin{document}
\chapter{test}
\clearpage
\begin{listing}[H] \mint{cl}/(car (cons 1 2))/
\caption{Example of a listing.}
\label{lst:example}
\end{listing}
\clearpage
Listing \ref{lst:example} contains an example of a listing.
\end{document}
So, my question is... Why is this happening?
EDIT 2:
In theory, the order of loading packages with \usepackage in principle doesn't matter. Real life, however...
Hyperref has the nasty property that sometimes it conflicts when it is put earlier, sometimes when it is put later than other widely used packages
So, is it fair to blame Hyperref for this?
captionpackage all six load orders should work fine now. See also: http://www.latex-community.org/forum/viewtopic.php?f=46&t=20075 – May 01 '13 at 18:05