\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{sample}{name={sample},description=
{an example}}

\AtEndDocument{\printglossaries}

\begin{document}
\gls{sample}, \gls[format=textbf]{sample}.
\end{document}