| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 11184 人关注过本帖
标题:【★】[原创]在MATLAB7.0中编译与发布可执行文件的详细步骤与一些问题解答【 ...
只看楼主 加入收藏
leki
Rank: 4
等 级:贵宾
威 望:10
帖 子:236
专家分:0
注 册:2007-4-15
收藏
 问题点数:0 回复次数:16 
【★】[原创]在MATLAB7.0中编译与发布可执行文件的详细步骤与一些问题解答【★】

这是我亲自做的,能在没有安装MATLAB的机子上成功实现运行

今天花了好几个小时才整理出此详细步骤,特拿出来与大家分享

具体步骤如下:(此方法适用于MATLAB 7.0

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 Data\MathWorks\MATLAB\R14\compopts.bat

From template: D:\MATLAB7\BIN\WIN32\mbuildopts\msvc60compp.bat

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

To get started, select MATLAB Help or Demos from the Help menu.

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.exe76M左右)文件

然后在没有装MATLAB的机子上安装MCRInstallerD:\MATLAB Component Runtime

(目录中,最好不要有空格,如用 D:\MCR 就可以了)

设置环境变量,右键点击“我的电脑”-》属性-》高级-》环境变量-》新建

变量名:Path

变量值:D:\MCR\v70\runtime\win32

然后运行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的用这个),这些是对应处理器的数值运算优化文件 }

先找到 $MATLAB7\bin\win32目录下的atlas_Athlon.dllAMD系列CPU使用)和atlas_P4.dll(奔4用)文件,放到MCR目录中(随便),然后设置环境变量

变量名:BLAS_VERSION

变量值:D:\MCR\v70\atlas_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”里,再编译就不会出错了

[此贴子已经被作者于2007-6-23 21:45:20编辑过]

搜索更多相关主题的帖子: 问题解答 文件 编译 
2007-06-23 20:12
danielliujp
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2006-11-30
收藏
得分:0 
谢谢了,还是有些看不懂,不知道能否打包程序

上有政策 下有对策
2007-06-24 10:34
abingchem
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:716
专家分:0
注 册:2004-12-30
收藏
得分:0 
好东西,值得珍藏,谢谢BZ

此人已消失
2007-06-24 18:39
cxmsb
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-6-26
收藏
得分:0 

我执行到第二步就有问题了:
mcc -mc Face_test_luminance

------------------------------------------------------------------------
Segmentation violation detected at Tue Jun 26 18:56:44 2007
------------------------------------------------------------------------

Configuration:
MATLAB Version: 6.5.0.180913a (R13)
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 2 Stepping 4, GenuineIntel
Virtual Machine: Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)

Register State:
EAX = 00000000 EBX = 00df72a0
ECX = 00000000 EDX = 00df60cc
ESI = 1717a2e4 EDI = 0a591090
EBP = 00df60fc ESP = 00df60ec
EIP = 10b742f8 FLG = 00010293

Stack Trace:
[0] common_context.dll:_internal_remove(0x00df7278, 0x1717a2e4, 0x0a591090 "Face_test_luminance", 0x00df7278) + 88 bytes
[1] common_context.dll:_fmgrReResolve(0, 0, 0x1717a2e4, 0) + 50 bytes
[2] common_context.dll:_fmgrResolveInfoForMex(0x00df7278, 0, 0x1717a2e4, 0x0a591090 "Face_test_luminance") + 26 bytes
[3] compiler.dll:_com_get_Mfile_record_for_function(0x00df6ae4, 0x14e45898, 0x0a591090 "Face_test_luminance", 0) + 415 bytes
[4] compiler.dll:_process_user_specified_m_files(0x00df6ae4, 0x00df6950, 0x00df6950, 0x00df6ae4) + 77 bytes
[5] compiler.dll:_M2CCpp(0x00df6950, 0x00df6a84, 0x10b0f549, 0x00df6ae4) + 96 bytes
[6] compiler.dll:_M2Target(0x00df6ae4, 0x00dfafcc, 0x00dfd1cc, 0x015dc428) + 46 bytes
[7] compiler.dll:_run_compiler_common(0x00dfd1cc, 0x00dfafcc, 0x00df6a5c, 0x00df6a3c) + 1081 bytes
[8] compiler.dll:_compiler(0x00dfafcc, 0x10af15a6, 39, 3) + 232 bytes
[9] mcc.dll:_try_compile(0x00dfd1ac, 0x00dfd19c, 0, 0x00dfd1f9) + 58 bytes
[10] libut.dll:_ut_try_catch(0x00dfd1ac, 0x00dfd19c, 0x10af14e0, 0x10af1520) + 61 bytes
[11] mcc.dll:_mexFunction(3, 0x00dfd5d0, 0, 0x00dfd6d4) + 546 bytes
[12] libmex.dll:_mexRunMexFile(0, 0x00dfd5d0, 2, 0x00dfd6d4) + 71 bytes
[13] m_interpreter.dll:void __cdecl inCallMexFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const,void (__cdecl*)(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const),struct _mex_context *,struct mexfiles *)(0, 0x00dfd5d0, 2, 0x00dfd6d4) + 476 bytes
[14] m_interpreter.dll:void __cdecl inRunMexFile(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const,struct mexfiles *)(0, 0x00dfd5d0, 2, 0x00dfd6d4) + 126 bytes
[15] m_interpreter.dll:void __cdecl inExecMexFile(int,int,struct mxArray_tag * * const,struct MATLAB_Function_tag *)(0, 2, 0x00dfd6d4, 0x015dc428) + 82 bytes
[16] m_interpreter.dll:_inExecFunction(0, 2, 0x00dfd6d4, 0x015dc428) + 38 bytes
[17] m_interpreter.dll:_inMMexExecute(536, 0x015dc428, 0, 2) + 533 bytes
[18] m_interpreter.dll:enum opcodes __cdecl inMMex(char const *,int,int,int,int *,int *)(0x01512f4c "mcc", 536, 0, 2) + 94 bytes
[19] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,struct inPcodeNest_tag volatile *)(2, 0, 0, 0x171a66b8) + 2143 bytes
[20] m_interpreter.dll:_inInterPcode(2, 0x00dfdc54, 0, 0) + 193 bytes
[21] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _m_parser_interface *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0, 0x7a87fa78, 0x00dfdc54, 0x00dfdcf8) + 174 bytes
[22] m_interpreter.dll:_inEvalStringWithIsVarFcn(0x0a68c818 "mcc -mc Face_test_luminance\n", 28, 0, 0) + 531 bytes
[23] m_interpreter.dll:_inEvalString(0x0a68c818 "mcc -mc Face_test_luminance\n", 28, 0, 0) + 50 bytes
[24] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0x0a68c818 "mcc -mc Face_test_luminance\n", 0, 2, 0x00dfde30) + 68 bytes
[25] m_interpreter.dll:_inEvalCmdNoEnd(0x0a68c818 "mcc -mc Face_test_luminance\n", 1, 0x0047f617, 11) + 16 bytes
[26] matlab.exe:_mnParser(0x01f3df4c, 271218, 0, 48) + 1001 bytes
[27] matlab.exe:_WinMain@16(4194304, 0, 271218, 1) + 3872 bytes
[28] matlab.exe:_WinMainCRTStartup(0x01f3df4c, 24, 0x7ffda000, 0x8054bb38) + 308 bytes
[29] kernel
32.dll:0x7c816fd7(0x0047172c, 0, 0, 0)

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:

1. Send this crash report to segv@mathworks.com for automated analysis.
For your convenience, this information has been recorded in:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\matlab_crash_dump.4068

2. Also, if the problem is reproducible, send the crash report to
support@mathworks.com along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed prior to this crash report
A technical support engineer will contact you with further information.

Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.

Error in ==> C:\toolbox\compiler\mcc.dll
请问是怎么回事啊?

2007-06-26 20:46
leki
Rank: 4
等 级:贵宾
威 望:10
帖 子:236
专家分:0
注 册:2007-4-15
收藏
得分:0 
请先看清楚,此方法我是在7.0版本中进行的,7.0版相比以前的版本有很多改进,自己可以查一下它们的区别
由于没有用6.5版,所以没办法给出好的意见

常见的GUI编程问题与解答 http://bbs./dispbbs.asp?boardid=216&id=148781&star=1#148781
2007-06-27 08:37
jinyujun2006
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-6-28
收藏
得分:0 

试一试

2007-06-30 12:10
leki
Rank: 4
等 级:贵宾
威 望:10
帖 子:236
专家分:0
注 册:2007-4-15
收藏
得分:0 
回复:(cxmsb)我执行到第二步就有问题了:mcc -mc F...
前两天编译一个程序时,遇到了和你一样的问题
这主要是因为程序中使用了一些不能用mcc命令的函数,具体是哪些函数,我记不清楚,你找书看一下吧

常见的GUI编程问题与解答 http://bbs./dispbbs.asp?boardid=216&id=148781&star=1#148781
2007-07-09 00:33
jiangcivin
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-7-6
收藏
得分:0 

请问没有选项2怎么办
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


只有0和1的,没有2.

2007-07-09 11:06
jiangcivin
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-7-6
收藏
得分:0 

还有我的是matlab7,安装VC6.0

2007-07-09 11:08
leki
Rank: 4
等 级:贵宾
威 望:10
帖 子:236
专家分:0
注 册:2007-4-15
收藏
得分:0 

装了VC6.0都没有选项2吗???这可真奇怪

建议重装一次VC再试 或者上网搜一下,看有没有和你一样的情况


常见的GUI编程问题与解答 http://bbs./dispbbs.asp?boardid=216&id=148781&star=1#148781
2007-07-10 16:42
快速回复:【★】[原创]在MATLAB7.0中编译与发布可执行文件的详细步骤与一些问题 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039978 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved