Possible reasons for a "qrc:/main.qml:-1 File not found" error
-
Hello all,
when I compile my app wit Qt 5.9 and try to start it on an embedded device it crashes with the following errors:QQmlApplicationEngine failed to load component qrc:/main.qml:-1 File not found
The app works with Qt 5.6.2 on the same embedded device (arm linux gnueabihf) but crashes with Qt5.8 and 5.9. It also runs perfectly on my desktop with Qt 5.9.
I don't know what happens here. Did they change the resource system?
Does anybody have a clue?Regards!
-
Hi,
Can you reproduce that with a minimal example ?
-
hi! i have absolutely the same trouble:
i reproduse it with absolutely minimal qml example
When i deploy qt 5.5 application on beaglebone device (arm linux gnueabihf) - then works perfectly
When i deploy qt 5.8 - the error appears:QQmlApplicationEngine failed to load component qrc:/main.qml:-1 File not found
// this somehow works but the window is blank
main.cpp:#include <QGuiApplication> #include <QQuickView> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQuickView view; view.setSource(QUrl::fromLocalFile("main.qml")); view.show(); return app.exec(); }
-
@Andrey-Shmelew your problem seems unrelated or a least different.
You are trying to load your .qml file using a relative path which is not same as @DuBu which is using Qt's resources to handle his .qml files.
-
I compiled Qt 5.9 with a divergent "prefix" configure option. (I wanted to keep my old 5.6 installation.) So to get my app working on the target platform I had to set the environment variable LD_LIBRARY_PATH to the prefix path.
The error was a bit misleading cause it was using my app compiled for 5.9 but the libraries of 5.6.Thanks for your time!
-
@Andrey-Shmelew Yes, but to a different path.
-
@Andrey-Shmelew It have been 5.9.1 libs, but yes. The 5.6.2 ones still exist in "/usr/lib".
-
- configure with --prefix "/your/new/path/on/target" (and other options you need)
- make
- make install
- copy resulting directory contents to target into "/your/new/path/on/target"
- set LD_LIBRARY_PATH=/your/new/path/on/target/lib" on target
-
@Andrey-Shmelew I don't know why your error says "qrc:/main.qml" when you try to load your main.qml from the local file system. But I would recommend to load your qmls from the resource system. For your main.qml this would look like this:
view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
It makes it a lot easier to deploy your app. Since all qml files are compressed and included in your app you just need to copy one file to deploy your app to the target.
-
@DuBu said in Possible reasons for a "qrc:/main.qml:-1 File not found" error:
I don't know
i don't know too...
When i deploy with qt 5.5 it did not complain, and i think, it compressed all qml files and included in my app and loaded all qml files and executable automatically to armhf device.Even if the application is running, I still can not find main.qml file on the device.
-
@Andrey-Shmelew If your really use the files from the resources (what your don't do when you write QUrl::fromLocalFile) it should be hard to find them on the device. I think they got extracted to a temporary folder somewhere no one knows, at least I do. Maybe there's a function to get that path, but I never cared.
I just use two lines of code to make sure to load the qml files from the resource:
(I use QQmlApplicationEngine instead of QQuickView)engine.addImportPath(QStringLiteral("qrc:/")); engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Additionally you have to make sure to never load components from the local file system (i.e with a Loader).