Does loadlibrary function loads all the functions in one dll?

조회 수: 8 (최근 30일)
SH
SH 2015년 10월 13일
댓글: Philip Borghesani 2015년 10월 14일
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?

채택된 답변

Philip Borghesani
Philip Borghesani 2015년 10월 13일
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
SH
SH 2015년 10월 14일
Thanks, Philip!
The long loading time is due to the large amount of functions. When I comment off some functions, it did load faster.
One relevant question, do you have any idea that loading dlls in other languages (say LabVIEW, C/C++ etc.) is different mechanism? It seems that they only load those used functions by default. But in Matlab, we need to manually disable loading unused functions.
Philip Borghesani
Philip Borghesani 2015년 10월 14일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by