您的位置:首页 > 编程语言 > MATLAB

(实验学习)MATLAB与C/C++混合编程之MATLAB调用C程序,转载的

2009-05-16 17:00 267 查看
转载源于:http://hi.baidu.com/renrsh/blog/item/69c664117abe0b18b9127bc1.html

>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Digital Visual Fortran version 6.0 in C:\Program Files\Microsoft Visual Studio
[2] Lcc C version 2.4.1 in D:\SOFTWARE\MATLAB\sys\lcc
[3] Microsoft Visual C/C++ version 6.0 in d:\software\C_installer
[0] None
Compiler: 3
Please verify your choices:
Compiler: Microsoft Visual C/C++ 6.0
Location: d:\software\C_installer
Are these correct?([y]/n):

Warning: Mex requires that the Microsoft Visual C++ 6.0
directories "VC98" and "Common" be located within the same parent directory.
(Expected to find a directory named "Common" in the directory 'd:\software\C_installer'.)   强烈怀疑是安装vc++时候,文件夹不统一,这个可能会造成一些问题..





显然,自己没有安装vc98

Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
From template:              D:\SOFTWARE\MATLAB\BIN\win32\mexopts\msvc60opts.bat
Done . . .
***************************************************************************
  Warning: The file extension of 32-bit Windows MEX-files was changed
           from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated 
           MEX-file will not be found by MATLAB versions prior to 7.1.
           Use the -output option with the ".dll" file extension to
           generate a MEX-file that can be called in previous versions.
           For more information see: 
           MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows
***************************************************************************

>> mex hello.c                                                                                                             (已经把hello.c放在当前目录下的,)
  Could not find the compiler "cl" on the DOS path.
  Use mex -setup to configure your environment properly.
  D:\SOFTWARE\MATLAB\BIN\MEX.PL: Error: Unable to locate compiler.
??? Error using ==> mex
Unable to complete successfully

>>

修改一下:

>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Digital Visual Fortran version 6.0 in C:\Program Files\Microsoft Visual Studio
[2] Lcc C version 2.4.1 in D:\SOFTWARE\MATLAB\sys\lcc
[3] Microsoft Visual C/C++ version 6.0 in d:\software\C_installer
[0] None
Compiler: 2
Please verify your choices:
Compiler: Lcc C 2.4.1
Location: D:\SOFTWARE\MATLAB\sys\lcc
Are these correct?([y]/n): y
Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
From template:              D:\SOFTWARE\MATLAB\BIN\win32\mexopts\lccopts.bat
Done . . .
***************************************************************************
  Warning: The file extension of 32-bit Windows MEX-files was changed
           from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated 
           MEX-file will not be found by MATLAB versions prior to 7.1.
           Use the -output option with the ".dll" file extension to
           generate a MEX-file that can be called in previous versions.
           For more information see: 
           MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows
***************************************************************************
>>  mex hello.c

>>  $表明成功地编译
>> mex abc.cpp
lcc preprocessor warning: abc.cpp:5 EOF inside comment
lcc preprocessor warning: abc.cpp:5 No newline at end of file
Error abc.cpp: 5  syntax error; found `*' expecting `)'
Error abc.cpp: 5  skipping `*' `p' `,'
Error abc.cpp: 5  missing identifier
Error abc.cpp: 5  syntax error; found `int' expecting `;'
Error abc.cpp: 5  syntax error; found `)' expecting `;'
Error abc.cpp: 5  skipping `)'
Error abc.cpp: 5  declared parameter `Width' is missing
Error abc.cpp: 5  declared parameter `Height' is missing
Error abc.cpp: 5  syntax error; found `end of input' expecting `{'
Error abc.cpp: 5  syntax error; found `end of input' expecting `}'
10 errors, 2 warnings
  D:\SOFTWARE\MATLAB\BIN\MEX.PL: Error: Compile of 'abc.cpp' failed.
??? Error using ==> mex
Unable to complete successfully

>> hello
hello,world!

解决方案:

>> 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.2
[6] Borland C/C++ version 5.0
[7] Borland C/C++ (free command line tools) version 5.5
[8] Digital Visual Fortran version 6.0
[9] Digital Visual Fortran version 5.0
[10] Lcc C version 2.4.1
[11] Microsoft Visual C/C++ version 7.0
[12] Microsoft Visual C/C++ version 7.1
[13] Microsoft Visual C/C++ version 6.0
[14] Microsoft Visual C/C++ version 5.0
[15] Open WATCOM C/C++ version 1.3
[16] WATCOM C/C++ version 11
[17] WATCOM C/C++ version 10.6

他们的主页:http://info.borland.com/devsupport/bcppbuilder/patches/ 这个基本上无速度.

                    http://www.rsdown.cn/downinfo/2122.html 这个网站不要乱点.

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: