How do I make sure that all the dependencies of shared libraries are included in a compiler build?

14 views (last 30 days)
I'm trying to make an executable of my MATLAB app which uses some shared libraries (camera drivers). The way I deal with handling libraries, I created a prototype *.m file and then use it when loading a library (all using the loadlibrary function).
The code runs fine from MATLAB but as soon as I build it using the MATLAB Compiler it throws an error:
Error using loadlibrary (line 419)
The specified module could not be found.
All that even though I've specified that the additional include and header folders in the build preferences.
I suspect that it has to do with the fact that somehow not all of the files in the shared library folders are included in the build.
Does anyone know the proper way to do shared libraries with MATLAB and its compiler?
  3 Comments
Kuba
Kuba on 1 Sep 2014
The drivers have an include folder with some header files and a bin folder with a bunch of dll's and one .lib file. Normally I just call loadlibrary with the name of the main thing in the folder, without extension (the loadlibrary finds it fine when I run it with Matlab). When I specified it should take the .lib it didn't work so I assume it usually takes the dll.
Image Analyst
Image Analyst on 1 Sep 2014
Like I said below I think you need the full filename. Put it in some known place on the target computer because of MATLAB's quirky way of putting stuff you include with their deploytool in some weird secret hidden folder. I assume you tried the -a option of mcc/deploytool to include all the files you need (though you don't need to do that if you put them in a known location like I suggested).

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 1 Sep 2014
Make sure you specify the full path (folder + base file name) of your DLL to loadlibrary(). Call exist(DLLFileName, 'file') before you call loadlibrary to see that it's actually there before you call loadlibrary().
Please see my attached file where I read a Measurement Computing device's digital I/O pin via load library and a DLL call. Also attached is how I make the prototype file.
  3 Comments
Image Analyst
Image Analyst on 1 Sep 2014
The compiler costs a fortune so I suggest you call them and get advice for why it takes so long. Might as well get your money's worth.
I have programs that are 5-10 thousand lines long and they compile in 1.5 to 3 minutes. Of course that's half of what it used to be now that I have SSDs (solid state drives) instead of HDDs.
Adam
Adam on 1 Sep 2014
Which version of Matlab do you have? I certainly noticed that Matlab Compiler took forever to compile even a simple UI with one button calling a single function in 2013b (I'm not sure which version the Compiler Toolbox was), but in 2014a it is a lot faster.

Sign in to comment.

Categories

Find more on C Shared Library Integration 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!