PDA

View Full Version : How to compile openCV with qmake



Lapsio
15th July 2012, 10:57
Hello. I've got quite strange problem - when I include <cv.h>, i'm getting a LOT of errors in opencv files like:


/usr/include/opencv2/core/types_c.h:1836:24: error: expected ‘;’ at end of member declaration
/usr/include/opencv2/core/types_c.h:1836:24: error: expected unqualified-id before ‘<<’ token
In file included from /usr/include/opencv/cv.h:63:0,
from ../Eyes/camera.hxx:7,
from ../Eyes/core.cpp:36:
/usr/include/opencv2/core/core_c.h:1670:47: error: expected ‘,’ or ‘...’ before ‘<<’ token
/usr/include/opencv2/core/core_c.h:1865:19: error: expected ‘;’ at end of member declaration
/usr/include/opencv2/core/core_c.h:1865:19: error: expected unqualified-id before ‘<<’ token

and many others (172 errors)
when I'm compiling this code out of qtcreator with command

g++ `pkg-config opencv --cflags --libs` objectivetest.cpp -o test

Everything is alright, but I don't have to add any code to get theese errors - just including <cv.h> cause them. I've added this to eyes.pro file:

INCLUDEPATH += \
$$system(./scripts/libcfg --cflags opencv)

LIBS += \
$$system(./scripts/libcfg --libs opencv)

And both - highgui and cv are getting errors during compilation.

wysota
15th July 2012, 11:30
Why don't you just use pkg-config capabilities built into qmake?

Lapsio
15th July 2012, 11:47
It hasn't helped. Errors are exactly the same. I've also tried add all paths manually, but these errors are still the same.
I've moved include to main file and now I'm getting error:

/usr/include/opencv2/flann/lsh_table.h:196:14: error: ‘use_speed_’ was not declared in this scope

I don't know if it's earlier error or later and I have completely no idea why changing including place changed anything.

wysota
15th July 2012, 11:54
The errors are not related to pkg-config. You need to find out what the first error is and what line it is triggered on. It might help if you change the order of includes or specify some define before including the file. Many people successfully use OpenCV with Qt so what you experience has to be related to your specific configuration.

Lapsio
15th July 2012, 13:15
These errors were caused by using defines of oerror and some other defines which are used by OpenCV. Sorry for trouble, I should revise my code before ask.