声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1532|回复: 8

[混合编程] 哪位高手指导一个问题

[复制链接]
发表于 2006-9-3 22:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我要实现MATLAB 的混合编程,因此必须有接口程序.
安装编译器.
首先安装mex -setup和mbuild -setup,都选择了相应编译器后.按确定:
Are these correct?([y]/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



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

使用道具 举报

发表于 2006-9-4 00:12 | 显示全部楼层
好像装成功了。不知道你执行“ cd(prefdir); mccsavepath;” 没有。如果不执行的话,每次用mcc都要设置一次。
 楼主| 发表于 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
 楼主| 发表于 2006-9-5 09:42 | 显示全部楼层
怎么会进桌面去了呢?
 楼主| 发表于 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
 楼主| 发表于 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
 楼主| 发表于 2006-9-5 16:21 | 显示全部楼层
等了一天了,也没人指导一下啊.自己也搞不出.郁闷死
发表于 2006-9-5 20:38 | 显示全部楼层
cd(prefdir);
指的应该是你要编译的文件所在的路径
 楼主| 发表于 2006-9-6 10:10 | 显示全部楼层
是的啊。我进入了
cd %MATLAB根目录下\extern\examples\mex
cd %MATLAB6p5p1\extern\examples\mex
或者手动点MATLAB上面的current directory选择这个路径,都试过了啊.
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-20 02:46 , Processed in 0.071408 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表