1

i'm new to qt and i installed the qt creator on my mac (os 10.8.5) and wanted to add the openCv library. I followed the instruction of this youtube tutorial (http://www.youtube.com/watch?v=i9hYiMXLZRs).. don't know if that matters.

my untitled5.pro file:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = untitled5
TEMPLATE = app

INCLUDEPATH = /usr/local/include

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

LIBS += -L/usr/local/lib \
     -1ibopencv_core \
     -1ibopencv_imgproc \
     -1ibopencv_features2d \
     -1ibopencv_highgui

FORMS    += mainwindow.ui

and the main.cpp:

#include "mainwindow.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    IplImage* img = 0;
    img = cvLoadImage("/Users/path/to/image.jpg");
    cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow("Example1");

    return a.exec();
}

It's just some code to test the library opencv. By running this code, i get two errors:

linker command failed with exit code 1 (use -v to see invocation)
[untitled5.app/Contents/MacOS/untitled5] Error 1

I absolute don't have a clue what to do, searching for answers for hours. Maybe someone can help me. Can you tell me what does the error message say and what could i've done wrong?

PixelBanana
  • 27
  • 1
  • 6

1 Answers1

0

Check your library names. In your pro file the first letter is 1 (number) instead of l:

-libopencv_core \
-libopencv_imgproc \
-libopencv_features2d \
-libopencv_highgui
Ivan
  • 2,007
  • 11
  • 15
  • oh you are right! i copied this file, so i didn't noticed. Thank you soo much! – PixelBanana Nov 19 '13 at 09:38
  • What are the file names of that libraries? Try to add another `l` near `-l` switch, for example : `-llibopencv_core` – Ivan Nov 19 '13 at 09:39
  • there are 3 versions. when i go to /usr/local/lib i can find: libopencv_core.2.4.7.dylib, libopencv_core.2.4.dylib, libopencv_core.dylib. do i need to write the .dylib? – PixelBanana Nov 19 '13 at 09:51
  • 1
    okay i got it! two things i did wrong. first: i changed the lib names from lopencv_... to libopencv_... because i found this names in the folder of the path. but it has to be just lopencv_... (than libraries found again) second: my program crashed. i changed the image path to an .png image. now it works. don't know for sure if it was the .jpg format or a wrong path. – PixelBanana Nov 20 '13 at 07:31