You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, November 12th 2016, 2:44pm

OpenCV with Qt linker problems

Hello together,

I've got a problem relatet to OpenCv and the QtCreator. I want to use the opencv library in a Qt application, but when I add it to my project, I get linker errors.

My .pro-File looks like that: (Here you can see, that I tried the weirdest things to get it to work)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#-------------------------------------------------
#
# Project created by QtCreator 2016-11-12T14:06:12
#
#-------------------------------------------------

QT   	+= core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = qtCvSRCR
TEMPLATE = app


SOURCES += main.cpp\
    	mainwindow.cpp

HEADERS  += mainwindow.h

FORMS	+= mainwindow.ui
#INCLUDEPATH += .
#INCLUDEPATH += /usr/local/include
#INCLUDEPATH += /usr/local/include/opencv2
#INCLUDEPATH += /usr/local/include/opencv2
#INCLUDEPATH += /usr/local/include/opencv2/core
#INCLUDEPATH += /usr/local/include/opencv2/highgui
#INCLUDEPATH += /usr/local/include/opencv2/imgproc
#INCLUDEPATH += /usr/local/include/opencv2/flann
#INCLUDEPATH += /usr/local/include/opencv2/photo
#INCLUDEPATH += /usr/local/include/opencv2/video
#INCLUDEPATH += /usr/local/include/opencv2/features2d
#INCLUDEPATH += /usr/local/include/opencv2/objdetect
#INCLUDEPATH += /usr/local/include/opencv2/calib3d
#INCLUDEPATH += /usr/local/include/opencv2/ml
#INCLUDEPATH += /usr/local/include/opencv2/contrib
##LIBS += `pkg-config opencv --cflags --libs`
##LIBS += -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio  -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
#LIBS += `pkg-config opencv --libs`
##INCLUDEPATH += /usr/local/lib/libdmtx.a;/usr/local/lib/libola.a;/usr/local/lib/libola.so;/usr/local/lib/libolaartnet.a;/usr/local/lib/libolaartnet.so;/usr/local/lib/libolaartnetconf.a;/usr/local/lib/libolaartnetconf.so;/usr/local/lib/libolacommon.a;/usr/local/lib/libolacommon.so;/usr/local/lib/liboladummy.a;/usr/local/lib/liboladummy.so;/usr/local/lib/libolae131.a;/usr/local/lib/libolae131.so;/usr/local/lib/libolae131conf.a;/usr/local/lib/libolae131conf.so;/usr/local/lib/libolaespnet.a;/usr/local/lib/libolaespnet.so;/usr/local/lib/libolaftdidmx.a;/usr/local/lib/libolaftdidmx.so;/usr/local/lib/libolagpio.a;/usr/local/lib/libolagpio.so;/usr/local/lib/libolagpiocore.a;/usr/local/lib/libolagpiocore.so;/usr/local/lib/libolakarate.a;/usr/local/lib/libolakarate.so;/usr/local/lib/libolakinet.a;/usr/local/lib/libolakinet.so;/usr/local/lib/libolamilinst.a;/usr/local/lib/libolamilinst.so;/usr/local/lib/libolaopendmx.a;/usr/local/lib/libolaopendmx.so;/usr/local/lib/libolaopenpixelcontrol.a;/usr/local/lib/libolaopenpixelcontrol.so;/usr/local/lib/libolaosc.a;/usr/local/lib/libolaosc.so;/usr/local/lib/libolapathport.a;/usr/local/lib/libolapathport.so;/usr/local/lib/libolarenard.a;/usr/local/lib/libolarenard.so;/usr/local/lib/libolasandnet.a;/usr/local/lib/libolasandnet.so;/usr/local/lib/libolaserver.a;/usr/local/lib/libolaserver.so;/usr/local/lib/libolaserverplugininterface.a;/usr/local/lib/libolaserverplugininterface.so;/usr/local/lib/libolashownet.a;/usr/local/lib/libolashownet.so;/usr/local/lib/libolaspi.a;/usr/local/lib/libolaspi.so;/usr/local/lib/libolaspicore.a;/usr/local/lib/libolaspicore.so;/usr/local/lib/libolastageprofi.a;/usr/local/lib/libolastageprofi.so;/usr/local/lib/libolatrigger.a;/usr/local/lib/libolatrigger.so;/usr/local/lib/libolauartdmx.a;/usr/local/lib/libolauartdmx.so;/usr/local/lib/libolausbdmx.a;/usr/local/lib/libolausbdmx.so;/usr/local/lib/libolausbpro.a;/usr/local/lib/libolausbpro.so;/usr/local/lib/libolausbproconf.a;/usr/local/lib/libolausbproconf.so;/usr/local/lib/libopencv_calib3d.so;/usr/local/lib/libopencv_core.so;/usr/local/lib/libopencv_features2d.so;/usr/local/lib/libopencv_flann.so;/usr/local/lib/libopencv_highgui.so;/usr/local/lib/libopencv_imgcodecs.so;/usr/local/lib/libopencv_imgproc.so;/usr/local/lib/libopencv_ml.so;/usr/local/lib/libopencv_objdetect.so;/usr/local/lib/libopencv_photo.so;/usr/local/lib/libopencv_shape.so;/usr/local/lib/libopencv_stitching.so;/usr/local/lib/libopencv_superres.so;/usr/local/lib/libopencv_ts.a;/usr/local/lib/libopencv_video.so;/usr/local/lib/libopencv_videoio.so;/usr/local/lib/libopencv_videostab.so;/usr/local/lib/libzxing.a;
##LIBS += /usr/local/lib/libdmtx.a;/usr/local/lib/libola.a;/usr/local/lib/libola.so;/usr/local/lib/libolaartnet.a;/usr/local/lib/libolaartnet.so;/usr/local/lib/libolaartnetconf.a;/usr/local/lib/libolaartnetconf.so;/usr/local/lib/libolacommon.a;/usr/local/lib/libolacommon.so;/usr/local/lib/liboladummy.a;/usr/local/lib/liboladummy.so;/usr/local/lib/libolae131.a;/usr/local/lib/libolae131.so;/usr/local/lib/libolae131conf.a;/usr/local/lib/libolae131conf.so;/usr/local/lib/libolaespnet.a;/usr/local/lib/libolaespnet.so;/usr/local/lib/libolaftdidmx.a;/usr/local/lib/libolaftdidmx.so;/usr/local/lib/libolagpio.a;/usr/local/lib/libolagpio.so;/usr/local/lib/libolagpiocore.a;/usr/local/lib/libolagpiocore.so;/usr/local/lib/libolakarate.a;/usr/local/lib/libolakarate.so;/usr/local/lib/libolakinet.a;/usr/local/lib/libolakinet.so;/usr/local/lib/libolamilinst.a;/usr/local/lib/libolamilinst.so;/usr/local/lib/libolaopendmx.a;/usr/local/lib/libolaopendmx.so;/usr/local/lib/libolaopenpixelcontrol.a;/usr/local/lib/libolaopenpixelcontrol.so;/usr/local/lib/libolaosc.a;/usr/local/lib/libolaosc.so;/usr/local/lib/libolapathport.a;/usr/local/lib/libolapathport.so;/usr/local/lib/libolarenard.a;/usr/local/lib/libolarenard.so;/usr/local/lib/libolasandnet.a;/usr/local/lib/libolasandnet.so;/usr/local/lib/libolaserver.a;/usr/local/lib/libolaserver.so;/usr/local/lib/libolaserverplugininterface.a;/usr/local/lib/libolaserverplugininterface.so;/usr/local/lib/libolashownet.a;/usr/local/lib/libolashownet.so;/usr/local/lib/libolaspi.a;/usr/local/lib/libolaspi.so;/usr/local/lib/libolaspicore.a;/usr/local/lib/libolaspicore.so;/usr/local/lib/libolastageprofi.a;/usr/local/lib/libolastageprofi.so;/usr/local/lib/libolatrigger.a;/usr/local/lib/libolatrigger.so;/usr/local/lib/libolauartdmx.a;/usr/local/lib/libolauartdmx.so;/usr/local/lib/libolausbdmx.a;/usr/local/lib/libolausbdmx.so;/usr/local/lib/libolausbpro.a;/usr/local/lib/libolausbpro.so;/usr/local/lib/libolausbproconf.a;/usr/local/lib/libolausbproconf.so;/usr/local/lib/libopencv_calib3d.so;/usr/local/lib/libopencv_core.so;/usr/local/lib/libopencv_features2d.so;/usr/local/lib/libopencv_flann.so;/usr/local/lib/libopencv_highgui.so;/usr/local/lib/libopencv_imgcodecs.so;/usr/local/lib/libopencv_imgproc.so;/usr/local/lib/libopencv_ml.so;/usr/local/lib/libopencv_objdetect.so;/usr/local/lib/libopencv_photo.so;/usr/local/lib/libopencv_shape.so;/usr/local/lib/libopencv_stitching.so;/usr/local/lib/libopencv_superres.so;/usr/local/lib/libopencv_ts.a;/usr/local/lib/libopencv_video.so;/usr/local/lib/libopencv_videoio.so;/usr/local/lib/libopencv_videostab.so;/usr/local/lib/libzxing.a;
#LIBS += `echo $(pkg-config --libs opencv)`
INCLUDEPATH += /usr/local/include/
LIBS += /usr/local/lib/libopencv_core.so.2.4.13
LIBS += /usr/local/lib/libopencv_highgui.so.2.4.13


My cpp-code looks like that (it's just for test reasons):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "mainwindow.h"
#include <QApplication>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	// read an image
       	cv::Mat image= cv::imread("img.jpg");
       	// create image window named "My Image"
       	cv::namedWindow("My Image");
       	// show the image on window
       	cv::imshow("My Image", image);
       	// wait key for 5000 ms
       	cv::waitKey(5000);
	MainWindow w;
	w.show();

	return a.exec();
}


Thanks for your help!