1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

opencvのバージョンをあげたら動作しなくなった。namespaceなんたらというエラーがでる

Posted at

概要

自作ライブラリのttLibCで、opencvを使ってカメラ映像を取得したりするプログラム書いてた。

で、opencvのライブラリをbrewでインストールしていた3.4.0から
ソースコードから取得したopencv3.4.1にして見たところ

In file included from util/opencvUtil.c:17:
In file included from /usr/local/include/opencv/cv.h:63:
In file included from /usr/local/include/opencv2/core/core_c.h:48:
In file included from /usr/local/include/opencv2/core/types_c.h:59:
/usr/local/include/opencv2/core/cvdef.h:485:1: error: unknown type name 'namespace'
namespace cv {
^
/usr/local/include/opencv2/core/cvdef.h:485:13: error: expected ';' after top level declarator
namespace cv {
            ^
In file included from util/opencvUtil.c:18:
In file included from /usr/local/include/opencv/highgui.h:46:
/usr/local/include/opencv2/highgui/highgui_c.h:139:9: error: expected ';' after top level declarator
CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
        ^
/usr/local/include/opencv2/highgui/highgui_c.h:139:10: error: expected identifier or '('
CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
         ^
4 errors generated.

こんなエラーが出て動作しなくなってた。

解決策

cを使わない。cppを使う。

原因

c言語からopencvを使ってたのがまずかったみたいです。

この追加された下の方の部分
/usr/local/include/opencv2/core/cvdef.h
スクリーンショット 2018-04-03 16.30.45.png

これのせいで、c言語なのにnamespaceを使おうとしてただけでした。

OPENCV_STDINT_HEADERを定義してやって色々すれば回避できるかもしれませんが、とりあえずソースをc++にしてしまえば大丈夫になるみたいなので、それで行こうかと思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?