Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    Qt in Education
    opencv opencv3.10 load imagmatrix sobel
    2
    8
    4904
    Loading More Posts
    • 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
      beginMyCoding last edited by beginMyCoding

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • B
          beginMyCoding @SGaist last edited by

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • B
              beginMyCoding @SGaist last edited by

              @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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by SGaist

                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 Reply Quote 0
                • B
                  beginMyCoding @SGaist last edited by

                  @SGaist How to compile it manually?

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • First post
                      Last post