How can I unload an automatically generated .dll file?

조회 수: 13 (최근 30일)
Marcus Arndt
Marcus Arndt 2018년 5월 28일
답변: Fangjun Jiang 2019년 5월 23일
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
version -modules
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:
bdclose('all')
clear all, clear classes, clear mex
As the .dll isn't a .mex file, I cannot use the mislocked or munlock functions. The function
unloadlibrary
also doesn't work, as the generated .dll does not have an accompanying header.
Deleting the file using the Windows command
delete /f file.dll
doesn't work either, nor does manually unregistering the .dll using
regsvr32 /u file.dll
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?
  댓글 수: 2
IronLikeABrian
IronLikeABrian 2019년 5월 23일
Hello I'm having the same problem. Is there anybody who has some suggestion?
Marcus Arndt
Marcus Arndt 2019년 5월 23일
@IronLikeABrian:
I eventually solved the problem by switching to OpenModelica. I must admit, it's not quite as comfortable as Dymola, but it's free and this specific problem doesn't occur.
Word of warning: it did, however, take me a while to calibrate the initial conditions of the model; it seems OpenModelica is not as forgiving as Dymola.
Sorry that I can't provide an answer that actually solves the problem, but I hope I could still help.

댓글을 달려면 로그인하십시오.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2019년 5월 23일
try "clear functions"?

카테고리

Help CenterFile Exchange에서 Create Standalone FMU에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by