New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundling QML/QtQuick may need 2 runs #25

Open
usercz opened this Issue Oct 3, 2016 · 19 comments

Comments

Projects
None yet
4 participants
@usercz

usercz commented Oct 3, 2016

as of title ("List depend on qtdeclarative5-dev-tools")

@usercz

This comment has been minimized.

usercz commented Oct 3, 2016

it errors out, about the lack of that binary. I don't know if it should actually be included in the appimage but isn't.

@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 3, 2016

Can you provide a link to the application that you are trying to bundle?

@usercz

This comment has been minimized.

usercz commented Oct 4, 2016

https://github.com/Swordfish90/cool-retro-term

This. I compiled it locally and it works fine.

@probonopd probonopd changed the title from List depend on qtdeclarative5-dev-tools to Bundling QML/QtQuick is not implemented yet Oct 4, 2016

This was referenced Oct 4, 2016

@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 7, 2016

sudo apt-get update
sudo apt install gitbuild-essential qmlscene libgl1-mesa-dev
cd cool-retro-term
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
cd cool-retro-term
export PATH=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/bin/:$PATH
qmake
make

./cool-retro-term 
# This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

export QT_PLUGIN_PATH=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/plugins/
export LD_LIBRARY_PATH=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/lib/
export QTDIR=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64 # not needed?

./cool-retro-term QQmlApplicationEngine failed to load component
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed
qrc:/main.qml:22 module "QtQuick.Window" is not installed
qrc:/main.qml:21 module "QtQuick" is not installed
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed
qrc:/main.qml:22 module "QtQuick.Window" is not installed
qrc:/main.qml:21 module "QtQuick" is not installed
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed
qrc:/main.qml:22 module "QtQuick.Window" is not installed
qrc:/main.qml:21 module "QtQuick" is not installed
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed
qrc:/main.qml:23 module "QtQuick.Controls" is not installed
qrc:/main.qml:22 module "QtQuick.Window" is not installed
qrc:/main.qml:21 module "QtQuick" is not installed

# When I do

export QML2_IMPORT_PATH=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/qml/

# then it runs.

Looks like the code to bundle QML is there but /home/me/build-linuxdeployqt-Desktop_Qt_5_7_0_GCC_64bit-Debug/linuxdeployqt/linuxdeployqt /home/me/cool-retro-term/cool-retro-term -qmldir=/home/me/cool-retro-term/qml -verbose=3 must be used.

When doing this, then some of the QML plugins do get copied to qml/ but the bundled app still complains:

QQmlApplicationEngine failed to load component
qrc:/main.qml:24 module "QtGraphicalEffects" is not installed

Cannot load QML interface

Copying in all the files under 5.7/gcc_64/qml/QtGraphicalEffects solves this, then we get

QQmlApplicationEngine failed to load component
qrc:/main.qml:132 Type ApplicationSettings unavailable
qrc:/ApplicationSettings.qml:26 Type Storage unavailable
qrc:/Storage.qml:22 module "QtQuick.LocalStorage" is not installed

Cannot load QML interface

Deploying 5.7/gcc_64/qml/QtQuick/LocalStorage would solve this.

When I copy in the missing parts manually, then the lack of running patchelf makes it not work (tries to load Qt components from system Qt in /sur/lib which obviously fails). However, when I run linuxdeployqt a second time, it does the patching.

So it is possible to bundle cool-retro-term with some manual tweaking, but linuxdeployqt still needs to be worked on, so that no manual intervention will be necessary.

@probonopd probonopd changed the title from Bundling QML/QtQuick is not implemented yet to Bundling QML/QtQuick is not working yet Oct 7, 2016

@probonopd probonopd changed the title from Bundling QML/QtQuick is not working yet to Bundling QML/QtQuick misses some imports Oct 7, 2016

@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 8, 2016

Working with some manual steps:

sudo apt-get update
sudo apt install gitbuild-essential qmlscene libgl1-mesa-dev
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
cd cool-retro-term
export PATH=/tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/bin/:$PATH
qmake
make
cd ..
wget https://transfer.sh/tlUbT/linuxdeployqt.appimage
chmod a+x linuxdeployqt.appimage
./linuxdeployqt.appimage /home/me/cool-retro-term/cool-retro-term -qmldir=/home/me/cool-retro-term/qmltermwidget/

# Work around https://github.com/probonopd/linuxdeployqt/issues/25
cp -r /tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/qml/QtQuick/Dialogs cool-retro-term/qml/QtQuick/
cp -r /tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/qml/QtQuick/PrivateWidgets cool-retro-term/qml/QtQuick/
cp -r /tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/qml/QtQuick/LocalStorage cool-retro-term/qml/QtQuick/

# Run again so that the manually copied in libraries get their rpath set
./linuxdeployqt.appimage /home/me/cool-retro-term/cool-retro-term -qmldir=/home/me/cool-retro-term/qmltermwidget/

cool-retro-term/cool-retro-term # runs!
@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 8, 2016

So the remaining question is:

Why doesn't it deploy

  • QtQuick/Dialogs
  • QtQuick/PrivateWidgets
  • QtQuick/LocalStorage

automatically?

@usercz

This comment has been minimized.

usercz commented Oct 10, 2016

It could be because AFAIK QML is run dynamically, so probably the files are loaded at runtime and paths do not appear in the binary?

@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 10, 2016

We might have inherited this issue:
https://bugreports.qt.io/browse/QTBUG-45977

@Larpon

This comment has been minimized.

Larpon commented Oct 10, 2016

The only "fix" I've been able to come up with in my python version was to let the user specify the dynamically loaded QML imports in the arguments like this:
--qml-import "QtMultimedia 5.0" --qml-import "QtQuick.Dialogs 1.2"

Then write a temporary dummy .qml file using those imports and run qmlimportscanner on that. Not beautiful but it works.

@probonopd

This comment has been minimized.

Owner

probonopd commented Oct 10, 2016

80aca76 Fix bundling of QtQuick/PrivateWidgets.
Still have to run linuxdeployqt twice so that it finds all Sql libs. Why?
Otherwise, works. No more manual copying needed.

@probonopd probonopd changed the title from Bundling QML/QtQuick misses some imports to Bundling QML/QtQuick may need 2 runs Oct 10, 2016

This was referenced Nov 29, 2016

probonopd added a commit that referenced this issue Feb 19, 2017

@probonopd

This comment has been minimized.

Owner

probonopd commented Feb 19, 2017

Still need to run twice, 4b2c81f

Revert this once running twice is no longer needed.

@probonopd

This comment has been minimized.

Owner

probonopd commented Feb 19, 2017

QtQuick.Layouts gets deployed now, but QtQuick.Controls doesn't. Why? What can we do to have it deployed automatically?

Would we have to parse all qml files for statements like

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

and deploy these? How do macedployqt and windeployqt solve this? Is this what qmlimportscanner is supposed to do?

@Larpon

This comment has been minimized.

Larpon commented Feb 19, 2017

Are you relying on qmlimportscanner?
Some of the guys at QtMob says it's got a bad habit of not finding things. I was recommended to have a dummy file, e.g. imports.qml in the project root directory with all (or troublesome) imports in it. So until it's fixed you might want to roll your own import scanner? :-/

@probonopd

This comment has been minimized.

Owner

probonopd commented Feb 19, 2017

Yes I am using qmlimportscanner, but perhaps I am running it with the wrong arguments?

@Larpon

This comment has been minimized.

Larpon commented Feb 19, 2017

It never hurts to double check - just wanted to note that it's known to be inconsistent in it's import discoveries (some runs work - some runs don't) - I've experienced it several times now with the version from 5.6.x

@probonopd

This comment has been minimized.

Owner

probonopd commented Feb 19, 2017

See #78 (comment) for my current suspicion

@TheAssassin

This comment has been minimized.

Collaborator

TheAssassin commented Nov 5, 2017

I guess the algorithm checking for libraries should just be implemented like here: https://github.com/Genymobile/copydeps

They just create a dependency tree (a real tree structure, see the graphics), then traverse the graph, and have the list of libraries to bundle. That shouldn't be too hard to implement on our side, too.

I'd love to be able to generate such graphs with linuxdeployqt, too.

@probonopd

This comment has been minimized.

Owner

probonopd commented Nov 5, 2017

PR welcome! 👍 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment