I am using a FMU (generated from Dymola 2018) in a Simulink model. When the model is compiled, a .dll file is created (among others). Now if I want to compile the model again, I receive warning that this file cannot be overwritten. I cannot delete the file manually because the file is in use. Using
I can see that the .dll file is loaded in MATLAB, even after closing the model.
After searching the depths of the Internet I have tried several solutions, none of which work, including:
clear all, clear classes, clear mex
As the .dll isn't a .mex file, I cannot use the mislocked or munlock functions. The function
also doesn't work, as the generated .dll does not have an accompanying header.
Deleting the file using the Windows command
doesn't work either, nor does manually unregistering the .dll using
The only way I can delete the file at the moment is to close MATLAB. Is this a common problem with imported FMU's? Why doesn't MATLAB unload the .dll automatically when the model is closed? Is there a way to force MATLAB to unload the .dll?