[Tex/LaTex] XeTeX hebrew problem with LyX

hebrewlanguageslyxxetex

I am using LyX and trying to write in Hebrew using XeTeX. I get the following error messages:

undefined control sequence
Package polyglossia error

Is this a package I should get manually? I would mention that the problem is only with Hebrew fonts. If I am writing an English document it compiles fine and there is no problem.

Edit

Ok, I have written a MWE and exported it to a TeX file, I got the following:

%% LyX 2.0.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,hebrew]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{David}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

\makeatother

\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
שלום עולם. זוהי דוגמה למסמך עברי\L{
\[
E=mc^{2}
\]
}זו הנוסחה המפורסמת של אינשטיין
\end{document}

The error messages are:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Fatal fontspec error: "cannot-use-pdftex"
The fontspec package requires either XeTeX or LuaTeX to function
You must change your typesetting engine to, e.g., "xelatex" or "lualatex"
instead of plain "latex" or "pdflatex"
See the fontspec documentation for further information
For immediate help type H <return>
...............................................  :    }

Best Answer

If you have a full TeXLive distribution, xelatex should be installed already, and you should be able to choose Document→Settings...→Fonts→Use non-TeX fonts (via XeTeX/LuaTeX) in LyX to have your document compile with xelatex. If that doesn't work, you need to tell us more about how your TeX distribution was installed.

Related Question