Can't build C++ Slint Application

I use Visual Studio Code on WSL and wanted to build the C++ / Slint 1.0 Hello World Application and run it on my Colibri iMX7 target. Unfortunately after pressing “Run and Debug” for Torizon ARMv7 the build process stops with the message shwon below.

Is there a description how I have to setup the Visual Studio Code environment to build the example on the Toradex homepage ?

:warning: VALIDATING ENVIRONMENT

:white_check_mark: Environment is valid!

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: bash -c [[ ! -z “192.168.1.109” ]] && true || false

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: bash -c [[ “armv7l” == “armv7l” ]] && true || false

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: sleep 1

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: sshpass -p torizon scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /home/torizon/test2/docker-compose.yml torizon@192.168.1.109:~/

Warning: Permanently added ‘192.168.1.109’ (ED25519) to the list of known hosts.

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: DOCKER_HOST=192.168.1.109:2375 docker-compose -p torizon down --remove-orphans

WARNING: The LOCAL_REGISTRY variable is not set. Defaulting to a blank string.
WARNING: The TAG variable is not set. Defaulting to a blank string.
WARNING: The DOCKER_LOGIN variable is not set. Defaulting to a blank string.
WARNING: The GPU variable is not set. Defaulting to a blank string.
Removing network torizon_default
WARNING: Network torizon_default not found.

  • Terminal will be reused by tasks, press any key to close it.

  • Executing task: DOCKER_HOST= docker build --pull -f /home/torizon/test2/Dockerfile.sdk /home/torizon/test2 -t cross-toolchain-arm-test2 --build-arg IMAGE_ARCH=arm

[+] Building 5.5s (5/6) docker:default
=> [internal] load build definition from Dockerfile.sdk 0.0s
=> => transferring dockerfile: 967B 0.0s
=> [internal] load metadata for docker.io/commontorizon/slint-sdk-arm:3.0.9-bookworm-1.3.0 0.4s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 56B 0.0s
=> CACHED [1/3] FROM docker.io/commontorizon/slint-sdk-arm:3.0.9-bookworm-1.3.0@sha256:91a5426062088e1f6ef9322a7146413519b848e1205b42d8e115853b10c7de84 0.0s
=> ERROR [2/3] RUN apt-get -q -y update && apt-get -q -y install && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/* 5.0s

[2/3] RUN apt-get -q -y update && apt-get -q -y install && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*:
0.323 Get:1 Index of /debian bookworm InRelease [151 kB]
0.349 Get:2 Index of /debian bookworm-updates InRelease [52.1 kB]
0.359 Get:3 Index of /debian-security bookworm-security InRelease [48.0 kB]
0.392 Get:4 Index of /debian bookworm/main armhf Packages [8497 kB]
0.401 Get:5 Index of /debian/snapshots/20230602T160948Z testing InRelease [13.0 kB]
0.643 Get:6 Index of /debian/snapshots/20230602T160948Z testing/main armhf Packages [10.7 kB]
0.987 Get:7 Kitware APT Repository jammy InRelease [15.5 kB]
1.159 Err:7 Kitware APT Repository jammy InRelease
1.159 The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 1A127079A92F09ED
1.950 Get:8 Index of /debian bookworm/main amd64 Packages [8787 kB]
3.555 Get:9 Index of /debian bookworm-updates/main armhf Packages [12.1 kB]
3.558 Get:10 Index of /debian bookworm-updates/main amd64 Packages [12.7 kB]
3.558 Get:11 Index of /debian-security bookworm-security/main amd64 Packages [134 kB]
3.585 Get:12 Index of /debian-security bookworm-security/main armhf Packages [129 kB]
4.312 Reading package lists…
4.930 W: GPG error: Kitware APT Repository jammy InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 1A127079A92F09ED
4.930 E: The repository ‘Kitware APT Repository jammy InRelease’ is not signed.


Dockerfile.sdk:16

15 | # automate for torizonPackages.json
16 | >>> RUN apt-get -q -y update &&
17 | >>> apt-get -q -y install
18 | >>> # DO NOT REMOVE THIS LABEL: this is used for VS Code automation
19 | >>> # torizon_packages_dev_start
20 | >>> # torizon_packages_dev_end
21 | >>> # DO NOT REMOVE THIS LABEL: this is used for VS Code automation
22 | >>> &&
23 | >>> apt-get clean && apt-get autoremove &&
24 | >>> rm -rf /var/lib/apt/lists/*

25
ERROR: failed to solve: process “/bin/sh -c apt-get -q -y update && apt-get -q -y install && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*” did not complete successfully: exit code: 100
  • The terminal process “/usr/bin/bash ‘-c’, ‘DOCKER_HOST= docker build --pull -f /home/torizon/test2/Dockerfile.sdk /home/torizon/test2 -t cross-toolchain-arm-test2 --build-arg IMAGE_ARCH=arm’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

Hi! This looks like an issue with the underlying base container and a possibly expired certificate for the cmake repo.

I’ll see about fixing this. Meanwhile, one thing that you could try as workaround is to add

RUN rm -f /etc/apt/sources.list.d/kitware.list

To your Dockerfile before the above failing command.

Edit: I tried it, can reproduce the issue. Workaround is to add RUN rm -f /etc/apt/sources.list.d/kitware.list in Dockerfile and Dockerfile.sdk before the first line that runs apt-get.

Edit v2: I made a fix upstream at Prospective fix for expiring cmake archive key breaking builds by tronical · Pull Request #6 · commontorizon/Containerfiles · GitHub . If that gets through, I’ll update this post with instructions how to change the Dockerfile :slight_smile:

@tronical Thank you for quickly following up on this!

Best Regards,
Jeremias

Quick follow-up (as I can’t edit anymore). Thanks to @matheus.tx updated base images are public now. The easiest and correct fix is to change

ARG CROSS_SDK_BASE_TAG=3.0.9-bookworm-1.3.0

in all your Docker files to

ARG CROSS_SDK_BASE_TAG=3.0.9-bookworm-1.3.2

As a bonus, this will also update Slint to the latest release :slight_smile:

@tronical , Thank you for the follow up.
Can we consider this topic as solved?

Best regards,
Josep

Yes, I think so :slight_smile:

After changing this definition to ARG CROSS_SDK_BASE_TAG=3.0.9-bookworm-1.3.2 I was able to build the docker container and the hello world application.

Thank you for that help.

After starting this application I get the following screen:

image

The application can’t be left, neither with the keyboard nor with the mouse. Do I have to enable the keyboard or the mouse ?

When I build the application, I get the following errors. Where do I have to set the include path in the Visual Studio Code, so that the compilers finds the include file “appwindow.h” ?

How can I get rid off the error with the Rust_COMPILER ?

Glad that you got it building and running on the device.

Regarding the build error for local builds: Unfortunately for the process of building you need to have Rust installed on your system. That’s best done by installing it locally using rustup. That should also remove the other error about appwindow.h. After installing Rust you may have to clean your project, i.e. remove the build directory.

The application is indeed running as fullscreen application. One thing that you could do is to edit your Dockerfile and remove the ENV SLINT_FULLSCREEN=1 line. Then you’ll see window decorations that you could use to quit.

Another - maybe more idiomatic - option would be to add keyboard handling to the example. For example, you could add a FocusScope that surrounds the rest of the UI and catches the escape key:

import { Button, HorizontalBox, VerticalBox, AboutSlint } from "std-widgets.slint";

export component AppWindow inherits Window {
    in-out property<int> counter: 42;
    callback request-increase-value();
    callback quit();
    FocusScope {
        VerticalBox {
            AboutSlint {  }
            Text {
                horizontal-alignment: center;
                text: "Counter: \{root.counter}";
            }
            HorizontalBox {
                alignment: center;
                Button {
                    text: "Increase value";
                    clicked => {
                        root.request-increase-value();
                    }
                }
            }
        }
        key-pressed(event) => {
            if (event.text == Key.Escape) {
                root.quit();
            }
            return reject;
        }
    }
}

and then in your main.cpp you could catch quit() and exit:

#include "appwindow.h"

#include <iostream>

int main(int argc, char **argv)
{
    auto ui = AppWindow::create();

    ui->on_request_increase_value([&]{
        ui->set_counter(ui->get_counter() + 1);
    });
    ui->on_quit([]{ std::exit(0); });

    std::cout << "Hello Torizon!" << std::endl;

    ui->run();
    return 0;
}

You could do the same with a Button, add one with the label “Quit” and then invoke quit() from the clicked callback, like so: Button { text: "Quit"; clicked => { root.quit(); } }.

1 Like