matlab111 发表于 2006-9-3 22:10

哪位高手指导一个问题

我要实现MATLAB 的混合编程,因此必须有接口程序.
安装编译器.
首先安装mex -setup和mbuild -setup,都选择了相应编译器后.按确定:
Are these correct?(/n):

The default options file:
"C:\Documents and Settings\new\Application Data\MathWorks\MATLAB\R13\compopts.bat"
is being updated from C:\MATLAB6P5P1\BIN\WIN32\mbuildopts\msvc60compp.bat...


--> "C:\MATLAB6p5p1\bin\win32\mwregsvr C:\MATLAB6p5p1\bin\win32\mwcomutil.dll"

DllRegisterServer in C:\MATLAB6p5p1\bin\win32\mwcomutil.dll succeeded

--> "C:\MATLAB6p5p1\bin\win32\mwregsvr C:\MATLAB6p5p1\bin\win32\mwcommgr.dll"

DllRegisterServer in C:\MATLAB6p5p1\bin\win32\mwcommgr.dll succeeded

Installing the MATLAB Visual Studio add-in ...

Updated C:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.awx
    from C:\MATLAB6P5P1\BIN\WIN32\MATLABWizard.awx
Updated C:\Program Files\Microsoft Visual Studio\common\msdev98\template\MATLABWizard.hlp
    from C:\MATLAB6P5P1\BIN\WIN32\MATLABWizard.hlp
Updated C:\Program Files\Microsoft Visual Studio\common\msdev98\addins\MATLABAddin.dll
    from C:\MATLAB6P5P1\BIN\WIN32\MATLABAddin.dll
Merged C:\MATLAB6P5P1\BIN\WIN32\usertype.dat
    with C:\Program Files\Microsoft Visual Studio\common\msdev98\bin\usertype.dat

Note: If you want to use the MATLAB Visual Studio add-in with the MATLAB C/C++
      Compiler, you must start MATLAB and run the following commands:

      cd(prefdir);
      mccsavepath;

      (You only have to do this configuration step once.)

出现上面的文字。是不是还没安装成功?



然后我根据飞思科技的那本书写的,想编译一个c文件为mex文件,以yprime.c为例进行.
写的是输入 cd(具体路径);mex yprime.c.但是出现了错误,它的显示如下:

> cd %MATLAB根目录下\extern\examples\mex

C:\MATLAB6p5p1\extern\examples\mex

>> mex yprime.c
yprime.c
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(132) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ','
C:\MATLAB6p5p1\extern\include\matrix.h(141) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2146: syntax error : missing ')' before identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2081: 'size_t' : name in formal parameter list illegal
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2061: syntax error : identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\tmwtypes.h(486) : fatal error C1189: #error :"This code must be compiled using a 2's complement representation for signed integer values"

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: Compile of 'yprime.c' failed.

??? Error using ==> mex
Unable to complete successfully



是不是编译器没安装成功啊?   哪位老师指导一下我.心里急!!

buaalqq 发表于 2006-9-4 00:12

好像装成功了。不知道你执行“ cd(prefdir); mccsavepath;” 没有。如果不执行的话,每次用mcc都要设置一次。

matlab111 发表于 2006-9-5 09:41

我现在是全部执行一遍了啊,但是好象用cd都进不了那里,真是奇怪了.
>> cd(prefdir);mccsavepath;
>> cd %MATLAB根目录下\extern\examples\mex

C:\Documents and Settings\new\Application Data\MathWorks\MATLAB\R13

>> mex yprime.c

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: 'yprime.c' not found.

??? Error using ==> mex
Unable to complete successfully

matlab111 发表于 2006-9-5 09:42

怎么会进桌面去了呢?

matlab111 发表于 2006-9-5 09:44

然后我手工把搜索路径点到C:\MATLAB6p5p1\extern\examples\mex.
然后再输入命令:mex yprime.c
原本应该显示编译成功,出现.dll文件的嘛,可是还是出错.
>> mex yprime.c
yprime.c
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(132) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ','
C:\MATLAB6p5p1\extern\include\matrix.h(141) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2146: syntax error : missing ')' before identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2081: 'size_t' : name in formal parameter list illegal
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2061: syntax error : identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\tmwtypes.h(486) : fatal error C1189: #error :"This code must be compiled using a 2's complement representation for signed integer values"

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: Compile of 'yprime.c' failed.

??? Error using ==> mex
Unable to complete successfully

matlab111 发表于 2006-9-5 10:17

不是输入MATLAB根目录下,而是输入MATLAB6p5p1,进入这个directory.或者我不用yprime.c而用其他的C文件来编译,都不行.这说明不是路径或是文件的问题了啊.
>> cd %MATLAB6p5p1\extern\examples\mex

C:\MATLAB6p5p1\extern\examples\mex

>> mex yprime.c
yprime.c
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(132) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ','
C:\MATLAB6p5p1\extern\include\matrix.h(141) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2146: syntax error : missing ')' before identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2081: 'size_t' : name in formal parameter list illegal
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2061: syntax error : identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\tmwtypes.h(486) : fatal error C1189: #error :"This code must be compiled using a 2's complement representation for signed integer values"

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: Compile of 'yprime.c' failed.

??? Error using ==> mex
Unable to complete successfully

>> mex mexget.c
mexget.c
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(131) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(132) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2146: syntax error : missing ')' before identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2061: syntax error : identifier 'n'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(139) : error C2059: syntax error : ','
C:\MATLAB6p5p1\extern\include\matrix.h(141) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2146: syntax error : missing ')' before identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2081: 'size_t' : name in formal parameter list illegal
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2061: syntax error : identifier 'size'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ';'
C:\MATLAB6p5p1\extern\include\matrix.h(153) : error C2059: syntax error : ')'
C:\MATLAB6p5p1\extern\include\tmwtypes.h(486) : fatal error C1189: #error :"This code must be compiled using a 2's complement representation for signed integer values"

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: Compile of 'mexget.c' failed.

??? Error using ==> mex
Unable to complete successfully

matlab111 发表于 2006-9-5 16:21

等了一天了,也没人指导一下啊.自己也搞不出.郁闷死

MVH 发表于 2006-9-5 20:38

cd(prefdir);
指的应该是你要编译的文件所在的路径

matlab111 发表于 2006-9-6 10:10

是的啊。我进入了
cd %MATLAB根目录下\extern\examples\mex
cd %MATLAB6p5p1\extern\examples\mex
或者手动点MATLAB上面的current directory选择这个路径,都试过了啊.
页: [1]
查看完整版本: 哪位高手指导一个问题