dongyong3554
dongyong3554
2015-02-15 06:07
浏览 142

SWIG中包含OpenCV core.hpp时的语法错误

I'm trying to use SWIG to wrap OpenCV's C++ API. However, when I compile, I got this error:

/usr/local/Cellar/opencv/2.4.10.1/include/opencv2/core/core.hpp:123:
Error: Syntax error - possibly a missing semicolon.

and here is my SWIG file

%module example

%{
#include "opencv2/core/core.hpp"
%}

%include "opencv2/core/core.hpp"

I'm not sure if this is an error from SWIG or from OpenCV. Is it OK to only include core.hpp like this?

Thanks.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用SWIG封装OpenCV的C ++ API。 但是,当我编译时,出现以下错误:

  /usr/local/Cellar/opencv/2.4.10.1/include/opencv2/core/core.hpp:123:  
错误:语法错误-可能缺少分号。
   
 
 

这是我的SWIG文件

 %module 例如
 
%{
#include“ opencv2 / core / core.hpp” 
%} 
 
%include“ opencv2 / core / core.hpp” 
   \  n 
 

我不确定这是来自SWIG还是来自OpenCV的错误。 这样只包含 core.hpp 可以吗?

谢谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douju2474
    douju2474 2015-02-16 06:42
    已采纳

    OK, I found the problem might be caused by the nested header including.

    In opencv2/core/core.hpp, there is

    #include "opencv2/core/types_c.h"
    #include "opencv2/core/version.hpp"
    

    and hence if I add these two headers to my swig file:

    %include "opencv2/core/types_c.h"
    %include "opencv2/core/version.hpp"
    %include "opencv2/core/core.hpp"
    

    It will not raise the missing semicolon error.

    点赞 评论

相关推荐