昊 天

Matlab编译COM组件的解决方案
 目前项目需要应用VS.net调用Matlab编译生成的COM组件。首先需要配置Matlab的C/C++编译器,由于我的VS.net并没有安装在C盘的根目录下,而在Matlab的命令行中输入mbuild -setup和mex -setup命令时,若选择mbuild to locate installed compilers,则找不到C/C++的编译器,无法完成编译器的配置(若用户的C/C++编译器安装在C盘默认路径上,则不会出现这个问题),从而导致使用Matlab COM Builder编译COM组件不成功,出现如下错误提示:


解决方法如下:(蓝色字体为用户输入命令)
>>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] Borland C++Builder version 6.0
[2] Borland C++Builder version 5.0
[3] Borland C++Builder version 4.0
[4] Borland C++Builder version 3.0
[5] Borland C/C++ version 5.02
[6] Borland C/C++ version 5.0
[7] Borland C/C++ (free command line tools) version 5.5
[8] Lcc C version 2.4
[9] Microsoft Visual C/C++ version 7.0
[10] Microsoft Visual C/C++ version 6.0
[11] Microsoft Visual C/C++ version 5.0 
[0] None 
Compiler: 9
The default location for Microsoft Visual C/C++ compilers is C:\Program Files\Microsoft Visual Studio .NET, but that directory does not exist on this machine. 
Use C:\Program Files\Microsoft Visual Studio .NET anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio .NET] D:\Program Files\Microsoft Visual Studio .NET 2003   (用户根据VC/VS.net的安装目录进行相应更改)
Please verify your choices:  

Compiler: Microsoft Visual C/C++ 7.0
Location: D:\Program Files\Microsoft Visual Studio .NET 2003  
Are these correct?([y]/n): y 
The default options file:
"C:\Documents and Settings\tutuya\Application Data\MathWorks\MATLAB\R13\compopts.bat"
is being updated from D:\MATLAB6P5\BIN\WIN32\mbuildopts\msvc70compp.bat...  
--> "D:\MATLAB6p5\bin\win32\mwregsvr D:\MATLAB6p5\bin\win32\mwcomutil.dll" 
DllRegisterServer in D:\MATLAB6p5\bin\win32\mwcomutil.dll succeeded 
--> "D:\MATLAB6p5\bin\win32\mwregsvr D:\MATLAB6p5\bin\win32\mwcommgr.dll" 
DllRegisterServer in D:\MATLAB6p5\bin\win32\mwcommgr.dll succeeded

>>mex -setup
Please choose your compiler for building external interface (MEX) files: 
Would you like mex to locate installed compilers [y]/n? n
 
Select a compiler:
[1] Borland C++Builder version 6.0
[2] Borland C++Builder version 5.0
[3] Borland C++Builder version 4.0
[4] Borland C++Builder version 3.0
[5] Borland C/C++ version 5.02
[6] Borland C/C++ version 5.0
[7] Borland C/C++ (free command line tools) version 5.5
[8] Compaq Visual Fortran version 6.1
[9] Compaq Visual Fortran version 6.6
[10] Digital Visual Fortran version 6.0
[11] Digital Visual Fortran version 5.0
[12] Lcc C version 2.4
[13] Microsoft Visual C/C++ version 7.0
[14] Microsoft Visual C/C++ version 6.0
[15] Microsoft Visual C/C++ version 5.0
[16] WATCOM C/C++ version 11
[17] WATCOM C/C++ version 10.6
 
[0] None
 
Compiler: 13
 
The default location for Microsoft Visual C/C++ compilers is C:\Program Files\Microsoft Visual Studio .NET,
but that directory does not exist on this machine. 
 
Use C:\Program Files\Microsoft Visual Studio .NET anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio .NET] D:\Program Files\Microsoft Visual Studio .NET 2003 (用户根据VC/VS.net的安装目录进行相应更改)

Please verify your choices:  
Compiler: Microsoft Visual C/C++ 7.0
Location: D:\Program Files\Microsoft Visual Studio .NET 2003  
Are these correct?([y]/n): y
 
The default options file:
"C:\Documents and Settings\tutuya\Application Data\MathWorks\MATLAB\R13\mexopts.bat"
is being updated from D:\MATLAB6P5\BIN\WIN32\mexopts\msvc70opts.bat...

C/C++编译器配置成功!

posted on 2006-05-08 21:17  Tutuya  阅读(5689)  评论(6编辑  收藏  举报