在SWIG中包含OpenCV core.hpp时出现语法错误。

huangapple go评论85阅读模式
英文:

Syntax error when include OpenCV core.hpp in SWIG

问题

我正在尝试使用SWIG来封装OpenCV的C++ API。然而,在编译时,我遇到了以下错误:

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

这是我的SWIG文件内容:

%module example

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

%include "opencv2/core/core.hpp"

我不确定这是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.

答案1

得分: 2

好的,我找到问题可能是由于嵌套的头文件引起的。

opencv2/core/core.hpp中,有以下代码:

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

因此,如果我将这两个头文件添加到我的swig文件中:

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

它将不会引发缺少分号的错误。

英文:

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.

huangapple
  • 本文由 发表于 2015年2月15日 14:07:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/28523496.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定