Can't get Matlab compiler and loadlibrary to work

3 次查看(过去 30 天)
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.

采纳的回答

Jacob Halbrooks
Jacob Halbrooks 2014-3-26
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 个评论
Philip Borghesani
Philip Borghesani 2014-3-26
The isdeployed if branch should read:
loadlibrary('..\classes\@S5_Com\S5_SPI_D2XX_DLL', @S5_SPI_D2XX_DLL, 'alias', h.libID);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by