How to understand the LaTeX warning “there were undefined references”?

Getting a warning about undefined references after the first LaTeX run is nothing to worry about. Just rerun LaTeX once or twice more and all cross-references should be resolved (including the one to lastpage).

On the other hand, if you have typos in your labels and/or in your cross-referencing commands, the warnings won't go away upon recompiling the code once or twice more. At that state, they become useful because they tell you something is amiss and needs to be corrected.


Placement of the label can also be an issue. For instance, in my case I had the following structure, and I couldn't correctly reference fig:2F43 with this:

\begin{figure*}
\label{fig:2F43} %This is bad, labels should always appear after captions.
\centering
\includegraphics[clip=true,trim=0cm 0cm 0cm 0cm, width=12cm]{2F43}
\caption{Illustration of the $F_1$ part of the ATP Synthase complex
  (PDB ID 1E79; \citealt{Gibbons2000,Bernstein1978,Gezelter}).
  TEXT TEXT  TEXT TEXT  TEXT TEXT  TEXT TEXT  TEXT TEXT
}
%\label{fig:2F43} <-- Should actually be here
\end{figure*}

The reason this is so is because \label takes an argument, which is typically generated by some other command (e.g. \caption or \section). More discussion is available at Why does an environment's label have to appear after the caption?.