Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. Is it configuration problem of opencv3.10 with qt 5.5? Showing Error "undefined reference to `cv::imread(cv::String const&, int)"
Forum Updated to NodeBB v4.3 + New Features

Is it configuration problem of opencv3.10 with qt 5.5? Showing Error "undefined reference to `cv::imread(cv::String const&, int)"

Scheduled Pinned Locked Moved Unsolved Qt in Education
opencvopencv3.10load imagmatrixsobel
8 Posts 2 Posters 5.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beginMyCoding
    wrote on 16 Mar 2016, 12:04 last edited by beginMyCoding
    #1

    Hello I want to implement sobel operator, so for that i need to read matrix of the input image. I tried to perform with cv::imread() but i am getting the error

    undefined reference to `cv::imread(cv::String const&, int)
    

    this is my code below

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        Mat src, dst;
        /// Load an image
        src = cv::imread("C:\\Users\\Prashanth KUMAR\\Pictures\\PhotoGrid_1448276690562.jpg");
          namedWindow("initial");
          imshow("initial", src);
    
              waitKey();
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    

    testSobel.pro

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = TestSobel
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    

    I read in some posts that it is the problem of including opencv libraries in Qt.

    But my Qt Build environment already has an opencv directory
    here is the screenshot below
    https://drive.google.com/file/d/0B6gtKf78_zVOLWFPWFFzRk5EeXc/view?usp=sharing

    Or is there any other way to link opencv 3.10 with Qt Creator 5.5 in windows?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Mar 2016, 22:54 last edited by
      #2

      Hi,

      You need to tell your compiler that you want to link against the OpenCV libraries otherwise it won't know anything about them.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply 18 Mar 2016, 10:06
      0
      • S SGaist
        16 Mar 2016, 22:54

        Hi,

        You need to tell your compiler that you want to link against the OpenCV libraries otherwise it won't know anything about them.

        B Offline
        B Offline
        beginMyCoding
        wrote on 18 Mar 2016, 10:06 last edited by
        #3

        @SGaist Thanks for your reply.
        I a new to Qt and OpenCV.
        Can you explain in detail how to do that, or any link which explains that would be helpful?
        I have searched a lot about this but nothing seems to work for me.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Mar 2016, 21:26 last edited by
          #4

          What did you try ?
          What error did you get ?
          What compiler are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply 19 Mar 2016, 09:47
          0
          • S SGaist
            18 Mar 2016, 21:26

            What did you try ?
            What error did you get ?
            What compiler are you using ?

            B Offline
            B Offline
            beginMyCoding
            wrote on 19 Mar 2016, 09:47 last edited by
            #5

            @SGaist I downloaded and extracted openCV. Later installed Qt. Added the directories
            C:\Qt\5.5\mingw492_32\bin
            C:\opencv\build\x86\vc12\bin
            to the path in Environment variables.

            Later downloaded CMake and installed it and added its path too.
            Created an empty folder opencv-mingw

            In CMake i selected
            the sourcecode Directory as C:\Qt\Tools\mingw492_32\bin
            Buid the binary in C:/opencv-mingw and hit configure button

            Selected MinGW Makefiles from dropdown menu. Then it asked to specify native compilers
            Specified C:/Qt/Tools/mingw491_32/bin/gcc.exe for C
            specified C:/Qt/Tools/mingw491_32/bin/g++.exe for C++
            and hit finish

            IT GAVE ME ERROR
            Error in configuration process, Project files may be invalid

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 19 Mar 2016, 20:50 last edited by SGaist
              #6

              You are trying to link a Visual Studio build of OpenCV with a MinGW build of Qt. That won't work.

              If already available in your package, use the MinGW version. Otherwise you have to compile OpenCV by hand.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              B 1 Reply Last reply 20 Mar 2016, 14:19
              0
              • S SGaist
                19 Mar 2016, 20:50

                You are trying to link a Visual Studio build of OpenCV with a MinGW build of Qt. That won't work.

                If already available in your package, use the MinGW version. Otherwise you have to compile OpenCV by hand.

                B Offline
                B Offline
                beginMyCoding
                wrote on 20 Mar 2016, 14:19 last edited by
                #7

                @SGaist How to compile it manually?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 20 Mar 2016, 18:30 last edited by
                  #8

                  Take a look at the answer here

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  1/8

                  16 Mar 2016, 12:04

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved