Clear Filters
Clear Filters

How can I speed up loadlirbrary for a C/C++ DLL?

12 views (last 30 days)
Our company provides a C/C++ DLL (with a pure C interface) and a MATLAB wrapper to use the functionality in MATLAB. It works quite well exept for the loadlibrary part which is very slow (up to 15 seconds depending on the pc). A customer reported that a DLL from another company is loaded much faster (only a few seconds). Another aspect I came across is that using loadlibrary for our DLL in C++ is very fast (less than one second). Of couse, MATLAB will always need more time because its a different platform. But 15 seconds are too long. We use Windows but plan to use Linux in future, too.
So my question is: how can I speed up loadlibrary of our DLL?
  • How can I modify the code of our C/C++ DLL to make MATLAB's loadlibrary faster?
  • Can I use MATLAB different to make loading my DLL faster?
My current code where I load the DLL is:
if(~libisloaded(c.libalias))
try
[notfound,warnings] = loadlibrary (dllFullFileName,headerFileName,'alias',c.libalias);
catch ME
errorMessage = sprintf('...');
errorMessage = sprintf('%s\n%s', errorMessage, ME.message);
error(errorMessage)
end
end

Accepted Answer

Walter Roberson
Walter Roberson on 13 Oct 2015
Use the prototype file and thunk file
This will prevent matlab from having to compile the interface with a compiler.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!