0%

Win10下Matlab 2010b与VC++6.0的配置

课设要求一定要使用 VC++6.0(不忍心吐槽),然后还要连 Matlab 对其数据进行调用,这边捣鼓了一下如何在 VC++6.0 中配置 Matlab 开发环境。

配置MATLAB2010B的MCC编译环境

一定要使用Matl2010b及以前的版本,Matlab2010b是最后一个兼容VC++6.0的MATLAB版本
打开matlab,在工作区输入mbuild -setup

1
2
3
4
>>mbuild -setup
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? n

这里选择n,自己手动选择编译器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Select a compiler:
[1] Lcc-win32 C 2.4.1
[2] Microsoft Visual C++ 6.0
[3] Microsoft Visual C++ 2005 SP1
[4] Microsoft Visual C++ 2008 Express
[5] Microsoft Visual C++ 2008 SP1
[6] Microsoft Visual C++ 2010
[7] Microsoft Visual C++ 2010 Express

[0] None

Compiler: 2

The default location for Microsoft Visual C++ compilers is C:\Program Files\Microsoft Visual Studio,
but that directory does not exist on this machine.

Use C:\Program Files\Microsoft Visual Studio anyway [y]/n? n

这里也选择n,自己手动找vc路径,因为win10的32位程序默认是安装在C:\Program Files (x86)下,所以vc的路径为C:\Program Files (x86)\Microsoft Visual Studio,如果自定义路径就自行选择

1
2
3
4
5
6
7
8
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio] C:\Program Files (x86)\Microsoft Visual Studio

Please verify your choices:

Compiler: Microsoft Visual C++ 6.0
Location: C:\Program Files (x86)\Microsoft Visual Studio

Are these correct [y]/n? y

这里选y就好了

1
2
3
4
Trying to update options file: C:\Users\ACM\AppData\Roaming\MathWorks\MATLAB\R2010b\compopts.bat
From template: C:\PROGRA~2\MATLAB\R2010b\bin\win32\mbuildopts\msvc60compp.bat

Done . . .

配置系统变量

选择高级系统设置,然后环境变量

添加matlab的路径:%Matlab%\R2010b\bin\win32

配置vc6.0的环境

在导航栏Tools中选择设置

目录选项卡中目录选择Include Files
路径填入
%MATLAB%\R2010b\extern\include
%MATLAB%\R2010b\extern\include\win32

在Librar files下填入
%MATLAB%\R2010b\extern\include\lib\win32\microsoft

在工程中选择设置

C/C++选项卡中分类选择预处理器
在附加包含路径中填入%MATLAB%\R2010b\extern\include

连接选项卡中对象/库模块

填入libsincplot.lib mclmcrrt.lib
两个之间是空格

这样就可以在 VC++6.0 中调用 Matlab 的方法。