Reputation: 71
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:
+
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
Upvotes: 1
Views: 4266
Reputation: 2505
Moving the namespace line did solve the compilation problem. The undefined reference is a linking problem. Congrats! That's progress.
Now you just have to determine which opencv lib has that symbol and confirm that your search paths are looking there (They probably are not). You can use readelf
to see the symbols inside any particular library. Your missing symbol probably supposed to be inside opencv_core, but I don't know that. You'll have to confirm. nm
might help you, too. Use man
to see how they work -- both are easy.
You can also track down the make file Qt creates, and use it from the command line. Add VERBOSE=1 to see every library asked for, and every path spelled out for library searches.
Upvotes: 1