0

I am new to C++ so this is probably a simple fix, but I have not been able to run my program even after reading Stack Overflow's many posts regarding openCV and Qt creator. This is now my 4th day trying to get openCV working in Qt creator, so any help would be greatly appreciated!

I know openCV is installed and working on my computer because I am able to build and run programs using it by running g++ pkg-config --libs --cflags opencv -o name name.cpp in terminal, just as long as I don't try to use openCV in Qt creator. I installed openCV through Homebrew and downloaded Qt creator from its website. I also have qt installed by running "brew install qt" in terminal.

I tried linking openCV to my Qt project by editing the project file which now reads:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = opencvTestQT2

TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

QT_CONFIG -= no-pkg-config

CONFIG += link_pkgconfig

PKGCONFIG += opencv

But upon trying to run it I get the error:

opencv development package not found

I have also tried adding to my project file lines such as:

INCLUDEPATH += /usr/local/Cellar/opencv/2.4.11_1/include/
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
LIBS += -L/usr/local/Cellar/opencv/2.4.11_1/lib -lopencv_imgcodecs -lopencv_highgui

but none of them allow my program to be built.

I am using a Mac running version 10.10.4, openCV 2.4, and Qt Creator 3.4.2 in case that helps.

Thanks in advance

Giesbrecht
  • 592
  • 1
  • 6
  • 13
  • Could you try with few more libraries '-lopencv_core -lopencv_features2d -lopencv_highgui -lopencv_shape -lopencv_ts -lopencv_imgproc -lopencv_photo -lopencv_imgcodecs' – Pramod Kumar Jul 07 '15 at 21:05
  • Thanks for the advice. After adding the libraries you mentioned with the line "LIBS += -L/usr/local/Cellar/opencv/2.4.11_1/lib -lopencv_core -lopencv_features2d -lopencv_highgui -lopencv_shape -lopencv_ts -lopencv_imgproc -lopencv_photo -lopencv_imgcodecs" in the project file, I still git the error "Opencv development package not found". I tried added all the openCV libraries, but still no change. I wonder if Qt creator can't find my openCV libraries or if there is a specific way I need to link them to Qt creator other than the way I already have. – Giesbrecht Jul 08 '15 at 19:27

2 Answers2

2

Click on projects on the left pane -> Build & Run -> on Build Environment, add Path to /usr/local/bin in order for qt creator to find the pkg-config.

Dae Choi
  • 31
  • 2
0

as Dae Choi said, the pkg-config is not found. Doing that procedure will work. Just remember to update the run as well.

This error will show:

Starting /Users/sgb/build-imagenes-Desktop_Qt_5_9_1_clang_64bit-
Debug/NBasic.app/Contents/MacOS/NBasic...
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: 
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
The program has unexpectedly finished.

Just update in Projects -> Build & Run -> Run -> DYLD_LIBRARY_PATH to unset. Save and compile again. There are other thread where you can check as well.

Qt application throws “dyld: Symbol not found: __cg_jpeg_resync_to_restart”

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
sgbzona
  • 63
  • 4