Important: Please read the Qt Code of Conduct -

Problem in static, not in dynamic !

  • 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:

    # 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
    TEMPLATE = app
    SOURCES += main.cpp \
    HEADERS += \


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


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


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

    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

    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.

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

  • @alex_malyu

    Hello, and thanks for your answer.

    How can I do this ?

  • Documentation:

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

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

  • 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 :'(.

  • I found!

    Must declare:

    QVideoWidget *widget = new QVideoWidget();

    And after:


    And that's all working!

Log in to reply