川沙南郊野公园:matlab GUI 编程——mcc转换m文件到应用程序(转)
来源:百度文库 编辑:偶看新闻 时间:2024/04/30 14:26:59
1.安装C编译器(前提是你的电脑已经安装了VC)
>> mbuild -setup 、/切记横杠前有空格
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc C version 2.4 in D:\MATLAB7\sys\lcc
[2] Microsoft Visual C/C++ version 6.0 in D:\Microsoft Visual Studio
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C/C++ 6.0
Location: D:\Microsoft Visual Studio
Are these correct?([y]/n): y
Try to update options file: C:\Documents and Settings\Leki\Application Da
From template:
Done . . .
--> "D:\MATLAB7\bin\win32\mwregsvr D:\MATLAB7\bin\win32\mwcomutil.dll"
DllRegisterServer in D:\MATLAB7\bin\win32\mwcomutil.dll succeeded
--> "D:\MATLAB7\bin\win32\mwregsvr D:\MATLAB7\bin\win32\mwcommgr.dll"
DllRegisterServer in D:\MATLAB7\bin\win32\mwcommgr.dll succeeded
2.在MATLAB中,将M文件编译成exe(可执行)文件
>> mcc -m guimcc
Warning: No matching builtin function available for D:\MATLAB7\toolbox\simulink\simulink\set_param.bi
>>
上面警告的解决方法:
将 \MATLAB7\toolbox\compiler\deploy\matlabrc.m 中的
81行 set_param(0,'PaperType',defaultpaper);
82行 set_param(0,'PaperUnits',defaultunits);
注释掉之后,又重新编译了一次,没有警告信息出来了
3.将编译生成的文件发布到没有MATLAB的电脑上
先在 $MATLAB\toolbox\compiler\deploy\win32下找MCRInstaller.exe(76M左右)文件
然后在没有装MATLAB的机子上安装MCRInstaller到D:\MATLAB Component Runtime
(目录中,最好不要有空格,如用 D:\MCR 就可以了)
设置环境变量,右键点击“我的电脑”-》属性-》高级-》环境变量-》新建
变量名:Path
变量值:D:\MCR\v70\runtime\win32
然后运行exe文件,每次都是出现DOS界面后,几秒钟就自动关闭了
GUI界面一次都运行不出来,也没有错误信息提示
解决办法:
{ 因为MATLAB需要用到处理器的数学运算部分(MATLAB默认用的是INTEL的数学处理单元),故需要设置一下BLAS(Basic Linear Algebra Subroutines,就是"基础线性几何子程序"的意思)环境变量.
先找到 $MATLAB7\bin\win32目录下的atlas_Athlon.dll(AMD系列CPU使用)和atlas_P4.dll(奔4用)文件,放到MCR目录中(随便),然后设置环境变量
变量名:BLAS_VERSION
变量值:D:\MCR\v70\atlas_Athlon.dll
这样设置以后,再运行exe文件就OK了。
注意事项:
编译过程中,很可能会有如下报错
>> mcc -m interface
Unable to locate close;contentwindow as a function on the MATLAB path
Warning: An object instance still exists.
Use the objectdirectory command to see a count of existing instances.
Depfun error: 'Unable to locate close;contentwindow as a function on the MATLAB path'
>>
这种情况是因为我将“close;contentwindow”语句写在按钮控件属性的“callback”里面了
{但是如果只是单个语句的话,是可行的(比如:只有contentwindow)}此时,只要将“close;contentwindow”语句写在M文件中按钮的“callback”里,再编译就不会出错了