In the following code, I define a theorem environment definition and write a figure and a definition:
\documentclass[12pt]{book}
\usepackage[francais, english]{babel}
\usepackage{amsthm}
\begin{document}
\newtheorem{definition}{Definition}
\tableofcontents
\chapter{Chapter}
\section{Section}
\begin{figure}
a
\caption{haha}
\end{figure}
\begin{definition}[title]
body
\end{definition}
% ------------------------------------------
% List of figures
\addcontentsline{toc}{chapter}{\protect\numberline{}List of Figures}
\listoffigures
\cleardoublepage
% ------------------------------------------
% List of Definitions
\chapter*{List of Definitions}
\markboth{List of Definitions}{List of Definitions}
\addcontentsline{toc}{chapter}{\numberline{}List of Definitions}
\makeatletter
\@starttoc{lod}
\makeatother
\end{document}
The List of Figures can be correctly generated in the appendix:

However, the List of Definitions is empty:

Does anyone know what to do to make the auto-generation of the list of definitions work?
Edit 1: The solution of @egreg works fine for me in a separate file. When I adapt it to my huge tex files, I have got the following message while compilation. Could anyone help? (Sorry that I could not make the code simpler and copy here)


