使用MEX编译C ++文件

时间:2012-07-10 11:02:49

标签: matlab mex

我想用MEX在MATLAB上编译C \ C ++文件。我先尝试mex -setup然后mex xyz.cpp。但我仍然收到错误

  

E:\ MATLAB~1 \ BIN \ MEX.PL:错误:编译' xyz.cpp'失败。

输入此命令时

mex -v mexDiscreteFlow.cpp BPFlow.cpp Stochastic.cpp

我得到以下输出

  

这是mex,版权所有1984-2007 The MathWorks,Inc。

     

- >在C:\ Users \ abc \ AppData \ Roaming \ MathWorks \ MATLAB \ R2008b中找到默认选项文件名   -------------------------------------------------- --------------
   - >选项文件= C:\ Users \ abc \ AppData \ Roaming \ MathWorks \ MATLAB \ R2008b \ mexopts.bat
        MATLAB = E:\ MATLAB~1
   - >编译器= lcc
   - >编译器标志:
           COMPFLAGS = -c -Zp8 -I" E:\ MATLAB~1 \ sys \ lcc \ include" -DMATLAB_MEX_FILE -noregistrylookup
           OPTIMFLAGS = -DNDEBUG
           DEBUGFLAGS = -g4
           arguments =
           名称开关= -Fo
   - >预链接命令=
   - > LINKER = lcclnk
   - >链接指令:
           LINKFLAGS = -tmpdir"。" -dll" E:\ MATLAB~1 \ extern \ lib \ win32 \ lcc \ mexFunction.def" -L" E:\ MATLAB〜1 \ SYS \ LCC \ lib中" -libpath" E:\ MATLAB~1 \ extern \ lib \ win32 \ lcc" " C:\用户\ ABC \ APPDATA \ LOCAL \ TEMP \ MEX_JT〜1 \ templib2.obj"
           LINKDEBUGFLAGS =
           LINKFLAGSPOST = libmx.lib libmex.lib libmat.lib
           名称指令= -o" mexDiscreteFlow.mexw32"
           文件链接指令=
           库。 link指令=
           Rsp文件指示符= @
   - >资源编译器= lrc -I" E:\ MATLAB~1 \ sys \ lcc \ include" -noregistrylookup -fo" mexversion.res"
   - >资源链接器=
  -------------------------------------------------- --------------

     

- > lcc -c -Zp8 -I" E:\ MATLAB~1 \ sys \ lcc \ include" -DMATLAB_MEX_FILE -noregistrylookup -FoC:\ USERS \ abc \ APPDATA \ LOCAL \ TEMP \ MEX_JT~1 \ mexDiscreteFlow.obj -IE:\ MATLAB~1 \ extern \ include -IE:\ MATLAB~1 \ simulink \ include -DNDEBUG - DMX_COMPAT_32 C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp

     

lcc预处理程序错误:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ ImageProcessing.h:7 C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ Image.h: 7 C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:3找不到包含文件
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:7语法错误;找到<' expecting;&#39;
  错误C:\用户\ ABC \ DOWNLO〜1个\ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ project.h:7跳跃<'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 7 syntax error; found
T&#39;期待;'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 7 syntax error; found
&gt;&#39;期待;'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 7 skipping
&gt;&#39;
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:8语法错误;找到*' expecting)&#39;
  错误C:\用户\ ABC \ DOWNLO〜1个\ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ project.h:8跳跃*' p缓冲器&#39;
  错误C:\用户\ ABC \ DOWNLO〜1个\ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ project.h:10未声明的标识符{{1} }删除&#39;
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11非法表达
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11语法错误;找到pBuffer'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 11 undeclared identifier
]&#39;
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11类型错误:指针预期<登记/>   警告C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11语句无效
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11语法错误;找到pBuffer' expecting;&#39;
  警告C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:11语句无效
  警告C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ project.h:11个可能的定义删除之前的使用
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:15语法错误;找到pBuffer' expecting;&#39;
  错误C:\用户\ ABC \ DOWNLO〜1个\ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\用户\ ABC \ DOWNLO〜1 \ RELEASE \ RELEASE \ MEX \ project.h:15跳过<' expecting T&#39;期待<'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 15 syntax error; found
&gt;&#39;期待;'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 15 syntax error; found
&gt;&#39;
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:16语法错误;找到;'
Error C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\mexDiscreteFlow.cpp: C:\USERS\abc\DOWNLO~1\RELEASE\RELEASE\MEX\project.h: 15 skipping
)&#39;
  错误C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ mexDiscreteFlow.cpp:C:\ USERS \ abc \ DOWNLO~1 \ RELEASE \ RELEASE \ MEX \ project.h:16太多错误

     

E:\ MATLAB~1 \ BIN \ MEX.PL:错误:编译&#39; mexDiscreteFlow.cpp&#39;失败。

     

???使用==&gt;时出错mex at 213
  无法成功完成。

有人可以提供一些建议吗?

谢谢

1 个答案:

答案 0 :(得分:4)

lcc是Matlab附带的 C 编译器,但您正在尝试编译 C ++ 文件。 你需要再次运行mex -setup并选择一个C ++编译器(但首先得到一个C ++编译器,如果你还没有它)