Qt via conan package manager - macOS - "Could not resolve plugin "qtquick2plugin""
-
Hello,
I am following this guide :
https://www.qt.io/blog/installing-qt-via-conan-package-manager
specifically this gif : https://www.qt.io/hs-fs/hubfs/conan_demo_app_build.gif?width=1600&name=conan_demo_app_build.gif .I am using the
macos-universal-clang
conan profile.I can build and run the "texteditor" Qt example application (unmodified), but when I run the built application, I get this error :
"
qt.qml.import: addImportPath: "/Users/myUser/.conan/data/qtbase/6.2.2/qt/everywhere/package/2b03afe371e4c5cfd9436080f6a933311ea6faef/qml"
qt.qml.import: addImportPath: "qrc:/qt-project.org/imports"
qt.qml.import: addImportPath: "/Users/myUser/Qt/Examples/Qt-6.2.1/quickcontrols2/texteditor/build/texteditor.app/Contents/MacOS"
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtQuick" invalid as ""
qt.qml.import: importExtension: qrc:/qml/texteditor.qml loaded ":/qt-project.org/imports/QtQuick/qmldir"
qt.qml.import: resolvePlugin Could not resolve plugin "qtquick2plugin" in ":/qt-project.org/imports/QtQuick"
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtQml" 6.2 as ""
qt.qml.import: importExtension: qrc:/qml/texteditor.qml loaded ":/qt-project.org/imports/QtQml/qmldir"
qt.qml.import: resolvePlugin Could not resolve plugin "qmlplugin" in ":/qt-project.org/imports/QtQml"
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtQml.Models" 6.2 as ""
qt.qml.import: importExtension: qrc:/qml/texteditor.qml loaded ":/qt-project.org/imports/QtQml/Models/qmldir"
qt.qml.import: resolvePlugin Could not resolve plugin "modelsplugin" in ":/qt-project.org/imports/QtQml/Models"
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtQml.WorkerScript" 6.2 as ""
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtCore" invalid as ""
qt.qml.import: addLibraryImport: qrc:/qml/texteditor.qml "QtQuick.Controls" invalid as ""
qt.qml.import: importExtension: qrc:/qml/texteditor.qml loaded ":/qt-project.org/imports/QtQuick/Controls/qmldir"
qt.qml.import: resolvePlugin Could not resolve plugin "qtquickcontrols2plugin" in ":/qt-project.org/imports/QtQuick/Controls"
QQmlApplicationEngine failed to load component
qrc:/qml/texteditor.qml:53:1: module "QtQuick.Controls" plugin "qtquickcontrols2plugin" not found
"What should I do to fix this?
-
I got it working :
A bit of context :
1.: official qt conan package MUST be consumed using the--generator=virtualenv
2.: this generator generatesactivate.sh
andenvironment.sh.env
3.:source activate.sh
must be called for both the build, and to run the built appSo the issue was that I was calling
source activate.sh
from my build script, so the variables weren't defined any more, when I tried to run my built app (outside of the script).So now I can use this script to run this texteditor example app (/Users/myUser/Qt/Examples/Qt-6.2.1/quickcontrols2/texteditor/) :
set -e conan install qtbuildprofiles/6.2.2@qt/everywhere -r qt conan install -u conanfile.txt --profile=macos-universal-clang --build=never --update --generator=virtualenv -r qt source activate.sh mkdir -p build cd build echo "cmake ../ -G Ninja -DCMAKE_BUILD_TYPE=Release" cmake ../ -G Ninja -DCMAKE_BUILD_TYPE=Release VERBOSE=1 cmake --build . --config Release --clean-first cd .. #Run the built app : ./build/texteditor.app/Contents/MacOS/texteditor