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!


  • Lifetime Qt Champion

    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();
    }
    

  • Lifetime Qt Champion

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



  • @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!



  • @Andrey-Shmelew

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.