use loadlibrary with a C dll several times, then throw an error " Error using loaddefinedlibrary"
I use the follow syntex:
loadlibrary('CDLL', 'EXPORT.h', 'mfilename', 'mxCDLL');
unloadlibrary('CDLL');
for i=1:1000
dll_name = 'CDLL';
if ~libisloaded(dll_name)
loadlibrary(dll_name, @mxCDLL);
end
end
and when the loop proceed the 495 time, it stoped, and throw an error "
Error using loaddefinedlibrary".
please help me, thank you very much!
ps: the CDLL.dll is programed by CUDA C, and I just load it and do nothing else.
8 Comments
Yes, it is extremely odd that libisloaded is false. Did you expect that your library would take a long time to load? Is that why you wrote the loop?
Could it be that at iteration 495, the library is finally loaded and thus loadlibrary complains?
You may want to monitor what is actually happening at the OS level with for example procmon.
Does the initialisation function of your library try to acquire resources that may be unavailable (hence, why it'd take a long time to load)?
To avoid us following red herrings, can you give us the exact code that you're testing with?
I don't know if it would help, but can you share your dll?
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!