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:MATLAB7syslcc
[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
SettingsLekiApplication
DataMathWorksMATLABR14compopts.bat
From
template: D:MATLAB7BINWIN32mbuildoptsmsvc60compp.bat
Done . . .
--> "D:MATLAB7binwin32mwregsvr
D:MATLAB7binwin32mwcomutil.dll"
DllRegisterServer in
D:MATLAB7binwin32mwcomutil.dll succeeded
--> "D:MATLAB7binwin32mwregsvr
D:MATLAB7binwin32mwcommgr.dll"
DllRegisterServer in
D:MATLAB7binwin32mwcommgr.dll succeeded
2.在MATLAB中,将M文件编译成exe(可执行)文件
>> mcc -m guimcc
To get started,
select MATLAB Help or Demos from the Help menu.
Warning: No matching builtin function available for
D:MATLAB7toolboxsimulinksimulinkset_param.bi
>>
上面警告的解决方法:
将 MATLAB7toolboxcompilerdeploymatlabrc.m
中的
81行
set_param(0,'PaperType',defaultpaper);
82行
set_param(0,'PaperUnits',defaultunits);
注释掉之后,又重新编译了一次,没有警告信息出来了
3.将编译生成的文件发布到没有MATLAB的电脑上
先在
$MATLABtoolboxcompilerdeploywin32下找MCRInstaller.exe(76M左右)文件
然后在没有装MATLAB的机子上安装MCRInstaller到D:MATLAB Component
Runtime
(目录中,最好不要有空格,如用 D:MCR 就可以了)
设置环境变量,右键点击“我的电脑”-》属性-》高级-》环境变量-》新建
变量名:Path
变量值:D:MCRv70runtimewin32
然后运行exe文件,每次都是出现DOS界面后,几秒钟就自动关闭了
GUI界面一次都运行不出来,也没有错误信息提示
解决办法:
{
因为MATLAB需要用到处理器的数学运算部分(MATLAB默认用的是INTEL的数学处理单元),故需要设置一下BLAS(Basic
Linear Algebra
Subroutines,就是"基础线性几何子程序"的意思)环境变量. 首先请确认你的MATLAB的文件夹中有如下文件:atlas_Athlon.dll(AMD系列的请用这个), atlas_P4.dll(P4的用这个),atlas_PIII.dll(P3的用这个),atlas_PII.dll(P2的用这个),这些是对应处理器的数值运算优化文件
}
先找到
$MATLAB7binwin32目录下的atlas_Athlon.dll(AMD系列CPU使用)和atlas_P4.dll(奔4用)文件,放到MCR目录中(随便),然后设置环境变量
变量名:BLAS_VERSION
变量值:D:MCRv70atlas_Athlon.dll
这样设置以后,再运行exe文件就OK了。
注意事项:
编译过程中,很可能会有如下报错
>> mcc -m
interface
To get started,
select MATLAB Help or Demos from the Help menu.
??? 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”里,再编译就不会出错了

被折叠的 条评论
为什么被折叠?



