[Tex/LaTex] lstlistings does not work in a slide

beamerlistings

I am writing a slide. I want to use lstlisting

    \documentclass[10pt]{beamer}
    \usepackage[utf8]{inputenc}
    \usepackage[english]{babel}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern} 
    \usepackage{listings}
    \begin{document}
    \begin{frame}{HeartBleed}
    \begin{lstlisting}
    Hellow world  
   \end{lstlisting}
   \end{frame}
   \end{document}

I get an error around around \begin{lstlisting} and it says: job aborted, no legal \end found. How can I resolve this problem ?

Best Answer

For the usage of listings you have to use the fragile option for the frame:

\documentclass{beamer}
\usepackage{listings}

\begin{document}
    \begin{frame}[fragile]
        \begin{lstlisting}
            Hello world  
        \end{lstlisting}
    \end{frame}
\end{document}

Further information can be at found http://pbelmans.wordpress.com/2011/02/20/why-latex-beamer-needs-fragile-when-using-verbatim/