Can't get Matlab compiler and loadlibrary to work
6 views (last 30 days)
Show older comments
Stian on 26 Mar 2014
Commented: Stian on 27 Mar 2014
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\' ...
-a '..\classes\' ...
-a '.\S5_SPI_D2XX_DLL.m' ...
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.
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?
More Answers (0)
Find more on Standalone Applications 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!