I want to include clickable links in my document that take you from a footnote or endnote in the body text to some material in the appendix. This problem is similar to the one posed in Making endnotes clickable links with hyperref, so I tried to use the hyperendnotes.sty code in Ryan Reich's answer to do so.
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{parskip}
\usepackage[toc,page]{appendix}
\usepackage{endnotes}
\let\footnote\endnote
\renewcommand\enoteheading{\chapter{Notes}}
\renewcommand\enoteformat{\leftskip=0pt \parindent=0em
\leavevmode\makeenmark\raggedright}
\usepackage[hyperfootnotes=true]{hyperref}
\usepackage{hyperendnotes}
\begin{document}
\tableofcontents
\chapter{chapter}
\section{section}
first\footnote{hello},
second\endnote{this is my equation
\begin{equation}
z=x+y
\end{equation}
}
third\endnote{another equation $a+b+c$}
\appendix
\addcontentsline{toc}{chapter}{Notes}
\theendnotes
\end{document}
but I get errors like Undefined control sequence. first\footnote{hello} and when I click on the links I am taken back to the first page. How do I fix this?

copy all that code into a file (say, hyperendnotes.sty) and \input or \usepackage it. So no extra code goes into the actual document.– Medulla Oblongata Jan 06 '17 at 13:19hyperref,endnotes,hyperendnotes? In that case I'm still getting the same error message – Medulla Oblongata Jan 06 '17 at 13:23