Can't get Matlab compiler and loadlibrary to work

조회 수: 8 (최근 30일)
Stian
Stian 2014년 3월 26일
댓글: Stian 2014년 3월 27일
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);
Stian
Stian 2014년 3월 27일
Finally, it worked! Thanks to both of you!

댓글을 달려면 로그인하십시오.

추가 답변 (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