Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Unsolved generate an exe on QT5.2 and OpenCV 3.1 in static mod.

    General and Desktop
    opencv qt5.2 static libwebp
    2
    6
    2544
    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.
    • ammarmoez
      ammarmoez last edited by ammarmoez

      Hello,
      I am a beginner in QT, and I want to generate a static application using OpenCV.
      I have already generated QT 5.2 in static modes, and opencv 3.1 also static mode using Mingw32.
      I can generate a qt.exe application, by using opencv and even exported to other PC.
      Once I added imread, i can't compile the code.
      Here are my files ..

      files.pro

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      TARGET = sans_titre4
      TEMPLATE = app
      
      message("* Using settings for Windows moez.")
      INCLUDEPATH += "C:\\OOpenCV\\buildQT6\\install\\include" \
                      "C:\\OOpenCV\\buildQT6\\install\\include\\opencv" \
                      "C:\\OOpenCV\\buildQT6\\install\\include\\opencv2"
      
      
      LIBS += -LC:\\OOpenCV\\buildQT6\\install\\x86\\mingw\\staticlib\
      -lIlmImf \
      -llibjasper \
      -llibjpeg \
      -llibpng \
      -llibtiff \
      -llibwebp \
      -lzlib \
      -lopencv_calib3d310 \
      -lopencv_core310 \
      -lopencv_features2d310 \
      -lopencv_flann310\
      -lopencv_highgui310 \
      -lopencv_imgcodecs310 \
      -lopencv_imgproc310 \
      -lopencv_ml310 \
      -lopencv_objdetect310 \
      -lopencv_photo310 \
      -lopencv_shape310 \
      -lopencv_stitching310 \
      -lopencv_superres310 \
      -lopencv_ts310 \
      -lopencv_video310 \
      -lopencv_videoio310 \
      -lopencv_videostab310 \
      
      
      SOURCES += main.cpp\
              mainwindow.cpp
      
      HEADERS  += mainwindow.h
      
      FORMS    += mainwindow.ui
      

      main.cpp

      #include "mainwindow.h"
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
      
          return a.exec();
      }
      

      mainwindow.h

      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      
      #include <opencv2/core/core.hpp>
      #include <opencv2/highgui/highgui.hpp>
      
      namespace Ui {
      class MainWindow;
      }
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      private slots:
          void on_pushButton_clicked();
      
      private:
          Ui::MainWindow *ui;
           cv::Mat m_zero ;
      };
      
      #endif // MAINWINDOW_H
      

      mainwindow.cpp

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QDebug>
      #include <QFileDialog>
      #include <QMessageBox>
      
      #include <cv.h>
      
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::on_pushButton_clicked()
      {
          m_zero = cv::Mat::zeros(10, 20, CV_32F);
      
          // Display dialog so the user can select a file
          QString filename = QFileDialog::getOpenFileName(this,
                                                          tr("Open Image"),
                                                          QDir::currentPath(),
                                                          tr("Files (*.png *.jpg *.tiff *.bmp)"));
      
          if (filename.isEmpty()) // Do nothing if filename is empty
              return;
      
      
          int Height = m_zero.size().height;
          QString::number(Height);
      
          qDebug() << Height ;
          QString Height_Qstring = QString::number(Height);
      
          m_zero = cv::imread("CSC_0113.JPG", CV_LOAD_IMAGE_COLOR);
          m_zero = cv::imread(filename.toStdString(), CV_LOAD_IMAGE_COLOR);
      
          QMessageBox msgBox;
          msgBox.setText(Height_Qstring + "   " + filename);
          msgBox.exec();
      
      
      }
      

      this the errors

      grfmt_webp.cpp:-1: erreur&nbsp;: undefined reference to `WebPGetFeaturesInternal'
      grfmt_webp.cpp:-1: erreur&nbsp;: undefined reference to `WebPDecodeBGRInto'
      :-1: erreur&nbsp;: C:\OOpenCV\buildQT6\install\x86\mingw\staticlib\libopencv_imgcodecs310.a(grfmt_webp.cpp.obj): bad reloc address 0x130 in section `.text$_ZN2cv11WebPDecoder8readDataERNS_3MatE'
      :-1: erreur&nbsp;: final link failed: Invalid operation
      collect2.exe:-1: erreur&nbsp;: error: ld returned 1 exit status
      
      

      if i comment this 2 lignes

       m_zero = cv::imread("CSC_0113.JPG", CV_LOAD_IMAGE_COLOR);
          m_zero = cv::imread(filename.toStdString(), CV_LOAD_IMAGE_COLOR);
      

      The code works, and the MsgBox displays the height of the matrix m_zero
      I have done several searches but I can not find a solution.

      cordially

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

        Hi and welcome to devnet,

        Don't have other warnings about the existence of some of the libraries you are linking to ? (e.g. libwebp)

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

        ammarmoez 1 Reply Last reply Reply Quote 0
        • ammarmoez
          ammarmoez @SGaist last edited by

          @SGaist thank for your response.

          I have no other error. this a scren shot
          https://drive.google.com/file/d/0B58fqnXmQyeSTUx5VmNlTGxBY2s/view?usp=drive_web

          and the source code.
          http://forum.qtfr.org/uploads/FileUpload/a9/a32a1992e83822a1765591fca0562b.rar

          1 Reply Last reply Reply Quote 0
          • ammarmoez
            ammarmoez last edited by

            In case when i use a Opencv non static library , i have this problem

            "Le programme s'est terminé subitement." french
            "The program ended suddenly." 
            
            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Dod you have the OpenCV .dlls folder in your PATH environment variable ? If not then go to the Run part of the Project panel and add it there (do not do it system wide).

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

              ammarmoez 1 Reply Last reply Reply Quote 0
              • ammarmoez
                ammarmoez @SGaist last edited by

                @SGaist
                yes all opencv files is included in the path.
                After some research in log file, i think I have a problème with the génération of libopencv_imgcodecs310 and libopencv_imgproc310 files.

                I'll keep you posted.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post