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. Problem in static, not in dynamic !
Forum Updated to NodeBB v4.3 + New Features

Problem in static, not in dynamic !

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.7k Views
  • 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.
  • J Offline
    J Offline
    JulienSmake
    wrote on last edited by
    #1

    Hello everyone.

    I come to you because I made a small test program, so only goal start a camera or webcam device.

    My problem, that is good when compiling dynamically, but if I compile in static method I get an error in the launch of my device.

    See for yourself.

    Dynamically compiled:
    Alt text

    I have a led on my test camera, which tells me when it is active, and all is good !

    Static compiled:
    Alt text

    Here, the LED stays off and i have error message ;'(.

    My code:

    camera.pro

    #-------------------------------------------------
    #
    # Project created by QtCreator 2015-06-10T19:54:09
    #
    #-------------------------------------------------
     
    QT       += core multimedia
    QT       -= gui
     
    TARGET = camera
    CONFIG   += static
    CONFIG   += console
    CONFIG   -= app_bundle
     
    static {
     CONFIG += static
     DEFINES+= STATIC
    }
    TEMPLATE = app
     
     
    SOURCES += main.cpp \
        camera.cpp
     
    HEADERS += \
        camera.h
    

    main.cpp

    #include <QCoreApplication>
    #include <camera.h>
     
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
     
        cameraObj * camera = new cameraObj();
     
        camera->start();
     
        return a.exec();
    }
    

    camera.h

    #ifndef CAMERA_H
    #define CAMERA_H
     
    #include <QMultimedia>
    #include <QCamera>
    #include <QCameraInfo>
     
    class cameraObj : public QObject
    {
        Q_OBJECT
     
        public:
            explicit cameraObj(QObject *parent = 0);
     
            QCamera* camera;
            QCameraInfo* cameraInfo;
     
        public slots:
            void start();
     
    };
     
    #endif // CAMERA_H
    

    camera.cpp

    #include "camera.h"
     
    cameraObj::cameraObj(QObject *parent) : QObject(parent)
    {
        camera = new QCamera;
        cameraInfo = new QCameraInfo;
    }
     
    void cameraObj::start()
    {
        qDebug() << cameraInfo->availableCameras();
        qDebug() << cameraInfo->deviceName();
        camera->start();
    }
    

    Note that I have no error or warning when compiling my little program, I have compiled Qt static with this script we just found on https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

    It is the first time I make in static, so I'm a little lost on the processing and resolution of my problem, if a charitable soul can help me I would greatly thankful him :)

    Thanks in advance.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      Static build has applies limitations and restrictions especially related to plug-in usage.
      You might need special handling to enable plug-n or some features might be disabled completely .

      J 1 Reply Last reply
      0
      • A alex_malyu

        Static build has applies limitations and restrictions especially related to plug-in usage.
        You might need special handling to enable plug-n or some features might be disabled completely .

        J Offline
        J Offline
        JulienSmake
        wrote on last edited by
        #3

        @alex_malyu

        Hello, and thanks for your answer.

        How can I do this ?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alex_malyu
          wrote on last edited by
          #4

          Documentation:
          http://doc.qt.io/qt-5/plugins-howto.html#static-plugins

          and keep in mind that I gave you only possible reason of the failure.

          J 1 Reply Last reply
          0
          • A alex_malyu

            Documentation:
            http://doc.qt.io/qt-5/plugins-howto.html#static-plugins

            and keep in mind that I gave you only possible reason of the failure.

            J Offline
            J Offline
            JulienSmake
            wrote on last edited by
            #5

            @alex_malyu

            Thank you, I'll read it immediately :)

            I would add that I have just compile the example provided in the QCamera doccumentation (available here) with changing nothing, and everything starts and runs without problems !

            Alt text

            Alt text

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JulienSmake
              wrote on last edited by
              #6

              I made the comparison with the example QCamera, and there is no QTPLUGIN or other parameter plugin you can see here.

              But I can compile the example in static without problem and all it works great!

              So it's a problem in my code :'(.

              J 1 Reply Last reply
              0
              • J JulienSmake

                I made the comparison with the example QCamera, and there is no QTPLUGIN or other parameter plugin you can see here.

                But I can compile the example in static without problem and all it works great!

                So it's a problem in my code :'(.

                J Offline
                J Offline
                JulienSmake
                wrote on last edited by JulienSmake
                #7

                I found!

                Must declare:

                QVideoWidget *widget = new QVideoWidget();
                camera->setViewfinder(widget);
                

                And after:

                camera->start();
                

                And that's all working!

                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