I am using Qt Creator on Ubuntu 15.04. I just installed OpenCV 3.0 using the script provided on the documentation website (here: https://help.ubuntu.com/community/OpenCV). When compiling my code i get some errors (not present before running the script):
/usr/include/opencv2/gpu/gpu.hpp:432: error: 'vector' does not name a type CV_EXPORTS void merge(const vector& src, GpuMat& dst, Stream& stream = Stream::Null());
/usr/include/opencv2/gpu/gpu.hpp:432: error: expected ',' or '...' before '<' token [..]
/usr/include/opencv2/gpu/gpu.hpp:438: error: 'vector' has not been declared [..]
All the errors are listed to be in 'gpu.hpp' besides the first one which is:
/[..]/main.cpp:6: In file included from ../[..]/main.cpp:6:0:
referring to the line in which I put the opencv2/gpu/gpu.hpp include.
I searched Stackoverflow a lot and moved 'using namespace std' before the includes but this just changes the error type (they all turn to
error: undefined reference to `cv::Mat::zeros(int, int, int)'
or something similar).
The includes I put at the top of the code are:
- iostream
- stdio.h
- opencv2/opencv.hpp, opencv2/highgui/highgui_c.h, opencv2/imgproc/imgproc_c.h, opencv2/gpu/gpu.hpp, opencv2/core/core.hpp
- vector
- math.h
- cmath
- list
- fstream
- string
- iomanip
+
using namespace std;
using namespace cv;
My .pro project file is:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = FinalMultimedia
TEMPLATE = app
LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
SOURCES += main.cpp\
Running the Makefile (make VERBOSE=1) I get:
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../try -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o main.o ../try/main.cpp
in which opencv libraries do not appear at all (dunno why). I am using gcc/g++ having just run update/upgrade so I guess it'll be 5.1.1. I am a complete Linux beginner, so I'm trying to figure it out. Any help? thank you very much.
UPDATE:
I tried to create a new Eclipse project with the same code inside. I set the right include / libraries (had been using opencv / c++ in ecplipse a while ago). I get the same error. wtf
pkg-config --libs opencv
. And what m.s. said.