使用matlab编译器生成EXE文件
(2012-09-03 16:58:15) 首先确定安装了C/C++编译器
然后在command window中作如下设置:
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? n
Select a compiler:
[1] Lcc-win32 C 2.4.1
[2] Microsoft Visual C++ 6.0
[3] Microsoft Visual C++ .NET 2003
[4] Microsoft Visual C++ 2005 SP1
[5] Microsoft Visual C++ 2008 Express
[6] Microsoft Visual C++ 2008 SP1
[0] None
Compiler: 6
The default location for Microsoft Visual C++ 2008 SP1 compilers is C:\Program Files\Microsoft Visual Studio 9.0,
but that directory does not exist on this machine.
Use C:\Program Files\Microsoft Visual Studio 9.0 anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 9.0] D:\Program Files\Microsoft Visual Studio 9.0
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1
Location: D:\Program Files\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
****************************************************************************
Warning: Applications/components generated using Microsoft Visual Studio
2008 require that the Microsoft Visual Studio 2008 run-time
libraries be available on the computer used for deployment.
To redistribute your applications/components, be sure that the
deployment machine has these run-time libraries.
****************************************************************************
Trying to update options file: C:\Documents and Settings\feiyuan\Application Data\MathWorks\MATLAB\R2009a\compopts.bat
From template: D:\PROGRA~1\MATLAB\R2009a\bin\win32\mbuildopts\msvc90compp.bat
Done . . .
设置完后,即可创建EXE文件了。(以peak.m文件为例)
在command window中输入:
mcc -m peak.m
这样在你设置的目录中即可生成一个名为peak的EXE文件。
注意:
- mcc -m peak.m命令中mcc与-之间有空格;
- 只有M函数文件才能生成EXE文件
- 如果在M文件的第一行有注释,在执行mcc -m后,会有如下提示:
Warning: MATLAB Toolbox Path Cache is out of date and is not being used.
Type ‘help toolbox_path_cache’ for more info