Search code examples
qtqmlqmakeqtmultimedia

How do I reconfigure Qt to detect a newly installed library?


Question what does it exactly mean to Reconfigure Qt and how do I do that after installing a library?

Context: As I am learning to develop applications in Qt, I keep running into a similar problem with a few different libraries, so I am asking a more general question because I think there is a pattern here that I am not understanding. However, I provide a particular example:

I want to use a USB camera view in my application. I have import QtMultimedia 5.0 in my qml file and created a camera widget based on a Qt-Creator example. When I go to run the application, I see the following error in application output:

[WARN | default] defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera" [:0] [WARN | default] defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer" [:0] And the camera view does not work (black screen). When I google this error I see a lot of thread that suggest installing a library and then reconfiguring Qt, for example as was suggested in this bug report.

I have two different development machines, one with a binary install of Qt and Qt Creator and on the other one I build Qt from source.


Solution

  • To reconfigure Qt implies to rebuild Qt, since configuration is the first step in building Qt.

    Qt is designed so that you can (and usually will!) have multiple versions installed in parallel on the same machine, in different installation folders. They will all be built from the same source. E.g. (on Unix), after you presumably installed the development packages for gstreamer, you'd have to build as follows:

    cd ~
    mkdir Qt
    wget https://download.qt.io/official_releases/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.xz
    tar -xf qt-everywhere-opensource-src-5.7.0.tar.xz
    

    Each configuration is built in its own set of build/install folders:

    mkdir 5.7.0-shared-build
    mkdir 5.7.0-shared
    cd 5.7.0-shared-build
    ../qt-everywhere-opensource-src-5.7.0/configure -prefix ../5.7.0-shared \
      -opensource -confirm-license -debug-and-release -gstreamer
    gmake -j8 && gmake -j8 install && echo OK
    cd ..
    
    mkdir 5.7.0-static-build
    mkdir 5.7.0-static
    cd 5.7.0-static-build
    ../qt-everywhere-opensource-src-5.7.0/configure -prefix ../5.7.0-static \
      -opensource -confirm-license -debug-and-release -static -gstreamer
    gmake -j8 && gmake -j8 install && echo OK
    cd ..
    

    The value of the -j argument to gmake should be set to the number of logical CPU cores on your machine.