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

时间:2016-08-31 18:34:26

标签: qt qml qmake qtmultimedia

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.

2 个答案:

答案 0 :(得分:2)

重新配置Qt意味着重建Qt,因为配置是构建Qt的第一步。

Qt的设计使您可以(并且通常会!)在同一台计算机上,在不同的安装文件夹中并行安装多个版本。它们都将使用相同的来源构建。例如。 (在Unix上),在你可能安装了gstreamer的开发包后,你必须按如下方式构建:

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

每个配置都在自己的一组构建/安装文件夹中构建:

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

gmake的-j参数值应设置为计算机上的逻辑CPU核心数。

答案 1 :(得分:1)

It sounds as if you need a Qt Plugin for the web camera and media player. The Qt Application cannot find those plugins (note, they're specifically compiled for use with Qt and with a specific version of Qt).

In QT C++, I would use the function QCoreApplication::addLibraryPath(const QString&), documented here: http://doc.qt.io/qt-5/qcoreapplication.html#addLibraryPath

I wouldn't call the above an "answer," but rather more like these are clues that could help you search for the answer you need to find.

相关问题