# Error when using minted package and -output-directory option

I am having problem when I use the -output-directory option while I am using minted. It does not move the .out.pyg and .pyg file to the output directory and it gives me an error.

I there any solution to order minted to put the auxilary files in the output directory not in root folder? MWE:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage{minted}
\begin{document}
\begin{minted}{c}
const double pi = 3.1415926535
\end{minted}
\end{document}

• Does it work fine (except for the location of the auxiliary files) if you remove the -output-directory option? – T. Verron May 7 '13 at 11:20
• @T.Verron, yes it works – rowman May 7 '13 at 11:24
• – G. Poore May 7 '13 at 17:16

You need \usepackage[outputdir=build]{minted} to tell minted where the files went.
If you have main.tex for example as your main file, an intermediate main.pyg is created in the root folder (despite having -output-directory switch) that will be deleted finally but is needed to properly typeset the source code. The solution is to make a shortcut to the main.pyg file and place it inside your -output-directory folder. The shortcut name should be main.pyg as well.