MATLAB: Do a get an error using ‘movefile’ when I generate code

codecodegenerrorgenerationmovefilertwbuildsimulink coder

I have a large model and I am using the parallel model reference build feature to speed up code generation. Building fails, however, with the nondescript error message 'Error using movefile, Unknown error occurred.'

Best Answer

This particular stack trace has been observed to be caused by third-party antivirus software interfering with Simulink. Please test whether you are able to generate code with your antivirus software disabled.
If your antivirus is not causing the error, then it is likely a file permissions issue. Please check that you have read and write permissions in your current working directory, the code generation folder, and the temporary directory (tempdir).