2024年4月29日发(作者:)

MATLAB方面的操作

1.先要完成Matlab C/C++编译器的设置,在matlab中:

>> 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

[5] Microsoft Visual C++ 2005 Express Edition

[6] Microsoft Visual C++ 2008

[0] None

Compiler: 6

The default location for Microsoft Visual C++ 2008 compilers is C:Program

FilesMicrosoft Visual Studio 9.0,

but that directory does not exist on this machine.

Use C:Program FilesMicrosoft Visual Studio 9.0 anyway [y]/n? n

Please enter the location of your compiler: [C:Program FilesMicrosoft Visual

Studio 9.0] D:Program FilesMicrosoft Visual Studio 9.0

Please verify your choices:

Compiler: Microsoft Visual C++ 2008

Location: D:Program FilesMicrosoft 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 SettingsAdministratorApplication

From template:

C:PROGRA~

Done . . .

2. 输入deploytool命令,写一个你所需要生成的动态链接文件的名称a[不要与函数名称

相重叠],在Target选择C shared library,确定,生成文件,在弹出的窗口中点

击add Files,将你所需要编译转换的matlab函数文件添加进去[支持嵌套函数,struct],

注意保证函数文件的正确性,否则后面容易出错。

C:Program FilesMATLABR2008atoolboxmatlabimagesciimread.m

3.点击build,生成src和distrib两个文件夹,build过程中的信息最好保存为log文件,

文件中的Link:......里面有很多.lib,都是C运行程序时所要调用到的静态链接文件,

在C文件中需添加进去。

4. 点击package,会自动将需要的文件打包为exe文件,里面包含,a.h,,

,最后运行时只需要这些文件就可以了,但是为了在工程中能看到编译后的原

matlab函数在C中的定义,从而便于编程和调试还需添加src文件夹下的

_component_data.c和a.c。