Can't get Matlab compiler and loadlibrary to work

9 views (last 30 days)
I'm trying to use the Matlab compiler to create a standalone version of a program. I'm running R2012b (32-bit) , with the standard Lcc-win32 provided by Matlab. I have to use 32-bit because I'm deploying for a 32-bit WinXP machine.
I'm getting an error about loadlibrary, which points to this web page, http://www.mathworks.com/access/helpdesk/help/toolbox/compiler/brb8oui.html , but it is missing.
The error message is "Deployed applications must use a prototype file instead of a header file. To create the prototype, use the loadlibrary mfilename option. Use the prototype file in compiled code."
I have been able to compile this previously, with R2012a or maybe an earlier version (can't recall). For some reason it doesn't work now.
My main program myprogram.m is in a folder C:\myprogram\source, from where I compile it. I'm trying to include a library S5_SPI_D2XX_DLL.dll in the subfolder C:\myprogram\classes\@S5_Com. That folder also contains S5_SPI_D2XX_DLL.h and @S5_Com.m.
My compile line is:
mcc -m myprogram.m ...
-o 'myprogram' ...
-d '..\compiled\' ...
-v ...
-N ...
-a '..\classes\' ...
-a '.\S5_SPI_D2XX_DLL.m' ...
-I '..\classes\'
and in my C:\myprogram\classes\@S5_Com\@S5_Com.m file I use the line
loadlibrary('..\classes\@S5_Com\S5_SPI_D2XX_DLL', 'S5_SPI_D2XX_DLL.h', 'alias', h.libID, 'mfilename', 'S5_SPI_D2XX_DLL.m');
Before compiling, I have run myprogram uncompiled from the Matlab CLI to generate the S5_SPI_D2XX_DLL.m file in the source folder. Still, I can't get this to work.
I have even tried to run the compiled myprogram.exe from the source folder, or copy the S5_SPI_D2XX_DLL.m file to the \compiled\ folder, but to no effect.

Accepted Answer

Jacob Halbrooks
Jacob Halbrooks on 26 Mar 2014
I suspect the correct reference page is here (I'll report the missing link as a bug).
From that reference page, it appears that you have the general workflow correct. I do notice that your LOADLIBRARY call includes both the header and the alias. Can you try calls like shown in the reference page, where the header is only included in the call in MATLAB but not in your deployed application?
  3 Comments
Philip Borghesani
Philip Borghesani on 26 Mar 2014
The isdeployed if branch should read:
loadlibrary('..\classes\@S5_Com\S5_SPI_D2XX_DLL', @S5_SPI_D2XX_DLL, 'alias', h.libID);
Stian
Stian on 27 Mar 2014
Finally, it worked! Thanks to both of you!

Sign in to comment.

More Answers (0)

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!