Does loadlibrary function loads all the functions in one dll?
4 views (last 30 days)
Show older comments
SH
on 13 Oct 2015
Commented: Philip Borghesani
on 14 Oct 2015
My problem is that loadlibrary takes long time to load all the functions in dll.
For example, I have A.dll and A.h, I use loadlibrary to load them, it would take several seconds. If I create a prototype file (A_proto.m) by loadlibrary, and invoke as loadlibrary('A.dll', @A_proto), it will save some time, but not enough.
My question is: Does MATLAB loads all the functions of the dll after I call "loadlibrary"? Even if I only use subset of the functions?
0 Comments
Accepted Answer
Philip Borghesani
on 13 Oct 2015
Yes, by default loadlibrary will load all functions found in the header file used to load or create the prototype file. The functions can be limited by modifying the header or commenting or removing functions and unneeded structures from the prototype file.
That said, unless there are a huge number of functions in the library I am not sure that is the cause of the problem. You might be better off profiling the loadlibrary call and or checking how long the prototype file takes to run by just running it from the command line.
For followup questions it would be useful to know what version of MATLAB you are using and on which platform. The loadlibrary line used to produce the prototype file would also be helpful.
What is the content of the second (notfound) output from loadlibrary?
2 Comments
Philip Borghesani
on 14 Oct 2015
It is possible that other packages deffer loading (calling getProcAddress) for functions until they are called. How the library is loaded changes dramatically because of thunkfile use between 32 and 64 bit programs so knowing what platform you are on would allow me to give better information.
More Answers (0)
See Also
Categories
Find more on C Shared Library Integration 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!