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:
I have a led on my test camera, which tells me when it is active, and all is good !
Static compiled:
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 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.
-
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 . -
-
Documentation:
http://doc.qt.io/qt-5/plugins-howto.html#static-pluginsand keep in mind that I gave you only possible reason of the failure.
-
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 !
-
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(); camera->setViewfinder(widget);
And after:
camera->start();
And that's all working!