英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论