cancel
Showing results for 
Search instead for 
Did you mean: 

qt aplication problem: Failed to create wl_display

nesnes
Associate III

Hello @Erwan SZYMANSKI 

I hope your week started well.

I think the script didn’t work because I couldn't adjust the paths correctly. Could you please assist me in finding the correct paths and adjusting my script accordingly?

 

 

 

 

# !/bin/sh

export QSG_INFO=1
export QML2_IMPORT_PATH=~/imports/
export PATH=/usr/local/qt5-install/bin/:/usr/local/apitrace/bin:$PATH
export QT_QPA_PLATFORM=wayland

#Execute the Qt program
export XDG_RUNTIME_SESSION=wayland; export XDG_RUNTIME_DIR=/run/user/1000; export WAYLAND_DISPLAY=wayland-1; cd /usr/bin && ./automotive
nesnes@nesnes-ABRA-A5-V19-2:/usr/local$ tree -L 2
.
├── bin
├── etc
├── games
├── include
├── lib
│   └── python3.10
├── man -> share/man
├── sbin
├── share
│   ├── ca-certificates
│   ├── fonts
│   ├── man
│   ├── sgml
│   ├── texmf
│   └── xml
└── src

 

 

 

 

24 REPLIES 24

Hello @nesnes 

 

just a quick check after looking at your last error message: "QQmlApplicationEngine failed to load component qrc:/Main.qml: No such file or directory":

 

Do you have similar line in your main.cpp application:

 

engine.addImportPath(QStringLiteral("qrc:/"));

 

Philippe.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
#include <QIcon>

int main(int argc, char *argv[])
{
    // Allow navigation.js to "GET" walk_route.json with XMLHttpRequest.
    qputenv("QML_XHR_ALLOW_FILE_READ", "1");

    QCoreApplication::setApplicationName("Wearable");
    QCoreApplication::setOrganizationName("QtProject");

    QGuiApplication app(argc, argv);

    //! [style]
    QQuickStyle::setStyle(QStringLiteral("WearableStyle"));
    //! [style]

    QQmlApplicationEngine engine;
#ifdef Q_OS_MACOS
    engine.addImportPath(app.applicationDirPath() + "/../PlugIns");
#endif

    // Use QUrl to load the main QML file
   engine.load(QUrl(QStringLiteral("qrc:/Wearable/Main.qml")));
 // Ensure your main QML file is correctly referenced

    // Check if loading failed
    if (engine.rootObjects().isEmpty()) {
        return -1;
    }

    return app.exec();
}

Hello @nesnes ,

 

I cannot understand why you have 

"qrc:/Wearable/Main.qml" path in your main.cpp 

and 

"qrc:/Main.qml: No such file or directory" error message?


There is an inconsistency between the log and the source. May be please double check around this.

 

BR,

Philippe.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

@PPAGE.13 The first version of .cpp was like the below code when I got the error and then I have changed it to qrc:/Wearable/Main.qml maybe the specifying the path would solve it but but after that I got the "qrc:/Wearable/Main.qml: No such file or directory" error line.

   engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));

 

@PPAGE.13I still havent solved my problem , can you help me to solve it.

@nesnes ,

i am rebuilding the full MP157 tree to be in line with last delivery. I am stuck today with "git.savannah.nongnu.org"  server down. I hope it will be solved it soon.
In the meantime, could you please tell me if you use Qt creator to build your application?

Philippe.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

@nesnes,

 

I strictly followed X-LINUX-QT guidelines:
https://wiki.st.com/stm32mpu/wiki/X-LINUX-QT_Expansion_Package#How_to_install_Distribution_Package

(Repo, build and flash image)

 

Then I generated an SDK: "bitbake st-image-qt -c populate_sdk"

 

Configure a Qt creator kit with that SDK. You can look at this post: https://stmicro.response.lithium.com/console/agent/22293782?

 

I have tested the official wearable example from Qt 5.15 (Qt/Examples/Qt-5.15.x/quickcontrols2/wearable/), compile and load it with Qt creator.

On target, you just need to run: /usr/share/examples/quickcontrols2/wearable/wearable

There is no need for any environment variable setup.

 

Hope this will help you,

Philippe.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

@PPAGE.13 

I followed the same steps but ı did not compile and load it with Qt creator. Instead I copied those wearable files to my own layer , and built it with qmake - make . I have tried the two version , one with sourcing the sdk crosscompile on the terminal and the other one compiled with the recipe.

SUMMARY = "Wearable Application (Prebuilt and Compiled from Source)"
DESCRIPTION = "Includes prebuilt wearable binary and also compiles wearable2 from source"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

# Ekstra dosya yollarını tanımlama - Yeni sözdizimi
FILESEXTRAPATHS:prepend := "${THISDIR}/files/src:"

SRC_URI = "file://src \
           file://src/Wearable \
           file://src/wearable.qrc"

S = "${WORKDIR}/src"

DEPENDS = "qtbase qtquickcontrols2 qtdeclarative"

inherit qmake5

# Install prebuilt wearable and build wearable2 from source
do_install() {
    install -d ${D}${bindir}
    install -d ${D}${datadir}/wearable

    # Install prebuilt executable
    install -m 0755 ${WORKDIR}/src/wearable ${D}${bindir}/wearable

    # Build from source
    cd ${S}
    qmake wearable.pro  # Specify the .pro file for qmake
    make

    # Install the source-built executable as wearable2
    install -m 0755 wearable ${D}${bindir}/wearable2

    # Install QML and resource files
    cp -r ${WORKDIR}/src/Wearable ${D}${datadir}/wearable/
}

FILES_${PN} = "${bindir}/wearable ${bindir}/wearable2"
~/STM32MPU-Ecosystem-v5.1.0/Distribution-Package/layers/meta-my-layer/recipes-apps/wearable$ tree -L 3 
.
├── files
│   └── src
│       ├── CMakeLists.txt
│       ├── doc
│       ├── Makefile
│       ├── qrc_wearable.cpp
│       ├── qrc_wearable.o
│       ├── wearable
│       ├── Wearable
│       ├── wearable.cpp
│       ├── wearable.o
│       ├── wearable.pro
│       ├── wearable.qrc
│       ├── WearableSettings
│       └── WearableStyle
└── wearable_1.0.bb

6 directories, 10 files

 

@PPAGE.13Firstly thank you for your help. I want to learn how to make it work on my yocto without using the Qt creator because Im using the open source version. I have added meta-qt5 layer to my image too. In the board I was getting

QQmlApplicationEngine failed to load component
qrc:/Wearable/Main.qml: No such file or directory

I have tried to solve it with this recommendation but still received the same error

 Loading Main.qml File Directly Using file:// Path

If loading Main.qml through the qrc path is still not working, you can try loading the file directly using the file:// path.
Loading Main.qml File Using file:// Path

    Locate the engine.load() line in your main.cpp or wearable.cpp file.

    Replace the qrc path with the file:// path as shown below:

    cpp

    engine.load(QUrl(QStringLiteral("file:///usr/share/wearable/Wearable/Main.qml")));

    After making this change, rebuild your application and run it again.

This will allow your application to load the Main.qml file directly from the specified file path instead of using the qrc resource path.

 

root@stm32mp15-disco:~# wearable
QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
QQmlApplicationEngine failed to load component
qrc:/Wearable/Main.qml: No such file or directory
root@stm32mp15-disco:~# wearable2
QStandardPaths: runtime directory '/run/user/1000' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 1000
QQmlApplicationEngine failed to load component
file:///usr/share/wearable/Wearable/Main.qml:9:1: module "WearableStyle" is not installed
file:///usr/share/wearable/Wearable/Main.qml:8:1: module "WearableSettings" is not installed
file:///usr/share/wearable/Wearable/Main.qml:9:1: module "WearableStyle" is not installed
file:///usr/share/wearable/Wearable/Main.qml:8:1: module "WearableSettings" is not installed

@nesnes 

please have a look at "https://github.com/STMicroelectronics/meta-st-x-linux-qt/blob/v1.0.0/recipes-st-launcher/stlauncher/stlauncher.bb" yocto recipe that should be very similar to what you need.

Might be following section missing:

 

RDEPENDS:${PN} = "\
   qtcharts \
   qtquickcontrols2-qmlplugins \
   qtxmlpatterns \
   qtxmlpatterns-qmlplugins \
   qtquicktimeline \
   qtquicktimeline-qmlplugins \
   qtdeclarative-qmlplugins \
   qtquickcontrols-qmlplugins \
   qtvirtualkeyboard \
   qtvirtualkeyboard-plugins \
   qtvirtualkeyboard-qmlplugins \
"

Philippe.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.