Generating C/C++ executable for a GUI program

I have Matlab GUI program that I want to convert in to a standalone executable using Matlab Coder. But when I try building the code, it gives me the following error:
>> coder -build Untitled1.prj
??? Function 'mfilename' is not supported for code generation. Consider using coder.extrinsic('mfilename') to bypass code generation.
The GUI code was built using Matlab GUIDE and the above error points to this part of the code:
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

 採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 11 月 1 日

0 投票

MATLAB Coder supports a limited subset of MATLAB functionality, which does not include GUIDE GUIs. You need to use the MATLAB Compiler product to deploy MATLAB GUIs.

3 件のコメント

M
M 2012 年 11 月 1 日
Thanks for the reply. MATLAB Compiler generates the executable, but it requires installation of the MATLAB MCR on the destination computer for the program to run. Is it possible to somehow avoid the MCR installation?
I think another approach might be to build the GUI in VC++ and let the background functions run from MATLAB but that would require some expertise in linking them together. Let's try.
Kaustubha Govind
Kaustubha Govind 2012 年 11 月 2 日
M: There's no way to get around the requirement for the MCR with MATLAB Compiler generated binaries. And yes, building the GUI in VC++ and driving code generated using MATLAB Coder is a good idea.
Gregoire Mahaut
Gregoire Mahaut 2017 年 3 月 24 日
I was wondering if anything had changed since 2012? Is there a way to compile GUI with Matlab Coder now?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Coder についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by