Solved Possible reasons for a "qrc:/main.qml:-1 File not found" error
-
@SGaist Yes, it's the same even with a "hello world" example.
Thanks for your reply. I found the reason for my case, see below. -
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!
-
@DuBu HI! did you downloaded any new-compiled libraries to armhf device?
-
@Andrey-Shmelew Yes, but to a different path.
-
@DuBu
you downloaded new *.so files (libQt5Gui.so.5.8.0, libQt5Qml.so.5.8.0...etc...) to a different path, but older *.so libraries still exsist, right? and you defined LD_LIBRARY_PATH to that new path...? -
@Andrey-Shmelew It have been 5.9.1 libs, but yes. The 5.6.2 ones still exist in "/usr/lib".
-
@DuBu sorry, the latest question:
How to properly put all new *.so.5.9.2 files to a different path , and how to tell new application to use these new libs instead so.5.6.2 ...???
very grateful!
-
- 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
-
@DuBu
cool, thanks -
@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).