Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. generate an exe on QT5.2 and OpenCV 3.1 in static mod.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
opencvqt5.2staticlibwebp
6 Posts 2 Posters 3.2k 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.
  • ammarmoezA Offline
    ammarmoezA Offline
    ammarmoez
    wrote on last edited by ammarmoez
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      ammarmoezA 1 Reply Last reply
      0
      • SGaistS SGaist

        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)

        ammarmoezA Offline
        ammarmoezA Offline
        ammarmoez
        wrote on last edited by
        #3

        @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
        0
        • ammarmoezA Offline
          ammarmoezA Offline
          ammarmoez
          wrote on last edited by
          #4

          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
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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

            ammarmoezA 1 Reply Last reply
            0
            • SGaistS SGaist

              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).

              ammarmoezA Offline
              ammarmoezA Offline
              ammarmoez
              wrote on last edited by
              #6

              @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
              0

              • Login

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