MATLAB: Do I receive the error “Cannot find the directory for Ghostscript” when I try to run the stand-alone application created by the MATLAB Compiler

aloneghostscriptMATLAB Compilerprintstandstandalone

I have a stand-alone application that prints to a pdf-file. When I run the stand-alone created by the MATLAB Compiler, I receive this error message:
Can not find the directory for Ghostscript in D:\MATLABR13sp1\bin\win32
This code will reproduce the problem:
function printtest
surf(peaks);
print -dpdf

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This is a bug in MATLAB Compiler 3.0.1 (R13SP1) in the way that the Compiler handles printing.
To work around this issue, copy the directory $MATLAB\sys\ghostscript to $MRTL\bin\$ARCH\sys\ghostscript (where $MGRTL is the root of your MGLINSTALLER installation and $ARCH is your architecture). You will also need to add $MGRTL\bin\$ARCH\ to your PATH. If you are unsure how to do this, see the Related Solution.