Ask Your Question
0

C compilation error

asked 2018-02-01 04:34:05 -0600

hanekiwi gravatar image

Hello, I want to use opencv in a C program. There is my code

#include "highgui.h"
#include "cv.h"
int main() {
}

But I got this error :

In file included from /usr/local/include/opencv2/core/core_c.h:48:0,
             from /usr/local/include/opencv/highgui.h:45,
             from opencv-test.c:6:
/usr/local/include/opencv2/highgui/highgui_c.h:139:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);

I looked at it on internet but I got no results. I think it's about a "::" operator in C code but I don't know how to fix it. I don't want to use C++ (because the project I'm working on require C). Any help thank you.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-02-01 04:45:23 -0600

berak gravatar image

updated 2018-02-01 04:53:36 -0600

support for C ended in 2010, you have to use c++ now.

even if you try to use the outdated (still existing) c-api headers & functions(and you should NOT !), you have to use a c++ compiler, not c99.

(because the project I'm working on require C).

do the following:

  1. seperate the opencv code from the rest of your project, compile the c++ opencv code seperately, using g++
  2. make your own c interface around your opencv code, so you can call it from your C project, without including opencv c++ headers
  3. link it all together.
edit flag offensive delete link more

Comments

thank you. This answered my question

hanekiwi gravatar imagehanekiwi ( 2018-02-01 04:51:18 -0600 )edit

@hanekiwi Please do not forget to upvote and accept as answer responses which address your issue. This allows for questions to be closed. Cheers :)

eshirima gravatar imageeshirima ( 2018-02-03 18:41:13 -0600 )edit

I can't upvote because this is my first question and I don't have enough Karma. By the way this is off topic but does someone know a C library that allow to access webcam input and process such input ?

hanekiwi gravatar imagehanekiwi ( 2018-02-03 18:51:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-02-01 04:34:05 -0600

Seen: 587 times

Last updated: Feb 01 '18