[Tex/LaTex] LaTeX Minted package using custom output-directory=build


Given the following LaTeX document (minimal.tex):

int main() {
    printf("hello, world");
    return 0;

I can build it with:

pdflatex -shell-escape  minimal.tex

But I would like to put the build files in another directory, so I use -output-directory=build, like:

pdflatex -shell-escape -output-directory=build minimal.tex

But this way I get:

[Loading MPS to PDF converter (version 2006.09.02).]
))) (./_minted-minimal/default-pyg-prefix.pygstyle)Error: cannot read infile: [Errno 2] No such file or directory: 'minimal.pyg'
system returned with code 256

! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.

l.9 \end{minted}

The minimal.pyg actually is inside build directory, but it seems not to be found.

What can I do?

Best Answer

You need \usepackage[outputdir=build]{minted} to tell minted where the files went.