Qt Template Project not working on Ubuntu Linux

Hello Toradex-Team,

I’m working on a Qt-Torizon project. Until the last days I always worked on my Windows10 Laptop in WSL2 and is works fine, but realy slow. So we set up a new Ubuntu 24.04 build server (native linux machine) with more power. But now the problem occurred that our Qt project no longer gets cross compiled for the Toradex Verdin AM62 (but Local ADM62 still works). I also tried to build a clean new Qt-Torizon-Template project, but the same behaviour occurred.

The problem seems to be in the build task “build-configure-arm64”
Here is the terminal output from the “build-configure-arm64” task:

 *  Executing task: pwsh -nop .conf/validateDepsRunning.ps1 


⚠️ VALIDATING ENVIRONMENT


✅ Environment is valid!

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

 *  Executing task: bash -c [[ ! -z "10.2.5.71" ]] && true || false 

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

 *  Executing task: bash -c [[ "aarch64" == "aarch64" ]] && 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 scemtec scp -P 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /home/u.nickmann/Projects/Other/qtTest2/docker-compose.yml torizon@10.2.5.71:~/ 

Warning: Permanently added '10.2.5.71' (ED25519) to the list of known hosts.
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: DOCKER_HOST=10.2.5.71:2375 docker image prune -f --filter=dangling=true 

Total reclaimed space: 0B
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: if [ false == false ]; then DOCKER_HOST=10.2.5.71:2375 docker compose -p torizon down --remove-orphans ; fi 

Warning: No resource found to remove for project "torizon".
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: DOCKER_HOST= docker build --pull -f /home/u.nickmann/Projects/Other/qtTest2/Dockerfile.sdk /home/u.nickmann/Projects/Other/qtTest2 -t cross-toolchain-arm64-qt-test2 --build-arg IMAGE_ARCH=arm64 --build-arg GPU= --build-arg APP_ROOT=/home/torizon/app 

[+] Building 0.5s (9/9) FINISHED                                                                                     docker:default
 => [internal] load build definition from Dockerfile.sdk                                                                       0.0s
 => => transferring dockerfile: 2.14kB                                                                                         0.0s
 => WARN: StageNameCasing: Stage name 'Build' should be lowercase (line 29)                                                    0.0s
 => [internal] load metadata for docker.io/torizon/qt6-wayland:3.2.0                                                           0.5s
 => [internal] load .dockerignore                                                                                              0.0s
 => => transferring context: 56B                                                                                               0.0s
 => [1/5] FROM docker.io/torizon/qt6-wayland:3.2.0@sha256:c0e3b66d647c7444392a69b5bf5cf746854bdcf25343561555414dcb1a97b0d0     0.0s
 => CACHED [2/5] RUN apt-get -q -y update &&         if [ "" = "-vivante" ] || [ "" = "-imx8" ]; then             apt-get -q   0.0s
 => CACHED [3/5] RUN apt-get -q -y update &&     apt-get -q -y install     build-essential     cmake     qt6-base-private-dev  0.0s
 => CACHED [4/5] RUN apt-get -q -y update &&     apt-get -q -y install     &&     apt-get clean && apt-get autoremove &&       0.0s
 => CACHED [5/5] WORKDIR /home/torizon/app                                                                                     0.0s
 => exporting to image                                                                                                         0.0s
 => => exporting layers                                                                                                        0.0s
 => => writing image sha256:aae109cdf799abb0df4ebfd6cdc9fdf204fd82195031e7a978147986edaecb73                                   0.0s
 => => naming to docker.io/library/cross-toolchain-arm64-qt-test2                                                              0.0s

 1 warning found (use --debug to expand):
 - StageNameCasing: Stage name 'Build' should be lowercase (line 29)
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: DOCKER_HOST= docker run --rm -v /home/u.nickmann/Projects/Other/qtTest2:/home/torizon/app cross-toolchain-arm64-qt-test2 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-arm64 

WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v4) and no specific platform was requested
CMake Error: Unable to (re)create the private pkgRedirects directory:
/home/torizon/app/build-arm64/CMakeFiles/pkgRedirects

 *  The terminal process "/bin/bash '-c', 'DOCKER_HOST= docker run --rm -v /home/u.nickmann/Projects/Other/qtTest2:/home/torizon/app cross-toolchain-arm64-qt-test2 cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-arm64'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

What does the error CMake Error: Unable to (re)create the private pkgRedirects directory: /home/torizon/app/build-arm64/CMakeFiles/pkgRedirects mean and how to get rid of it? It may have something to do with the CMake permission? But I dont get it…

Any suggestions?

Regards Uwe

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

The error you’re encountering, CMake Error: Unable to (re)create the private pkgRedirects directory: /home/torizon/app/build-arm64/CMakeFiles/pkgRedirects, typically indicates a permissions issue within the Docker container where CMake is trying to write to a directory it doesn’t have write access to. This can happen for a few reasons, especially when dealing with volume mounts (-v option) in Docker, where the host directory’s permissions are carried into the container.

Here are a few steps to troubleshoot and potentially resolve this issue:

  1. Check Ownership and Permissions: Ensure that the directory on your host machine (/home/u.nickmann/Projects/Other/qtTest2) has the correct permissions and is owned by the user running the Docker commands. You can adjust permissions with chmod and ownership with chown.

  2. Specify User in Dockerfile: If the Docker container runs as a user different from the host or as root, you might face permission issues. You can specify the user that the Docker container should run as, either by using the USER directive in your Dockerfile or by passing the --user flag to docker run. Make sure this user has the necessary permissions to write to the mounted directory.

  3. Use Docker’s --user Flag: When running the Docker container, you can match the user ID (UID) and group ID (GID) with your host’s UID/GID using the --user flag. For example: docker run --rm --user=$(id -u):$(id -g) -v /home/u.nickmann/Projects/Other/qtTest2:/home/torizon/app cross-toolchain-arm64-qt-test2 cmake .... This ensures that the container process has the same permissions as your host user.

  4. Adjust Docker Volume Permissions: Sometimes, adjusting the permissions of the volume directory from within the Dockerfile or entry script of the container can resolve the issue. Commands like chown or chmod can be used to adjust permissions so that the container user has write access to the necessary directories.

  5. Debugging with an Interactive Container: If the issue persists, try running an interactive container with a shell to manually check permissions and attempt file creation within the /home/torizon/app/build-arm64/CMakeFiles/ directory. This can help identify if the issue is indeed permissions or something else. Use `docker run -it --entrypoint /

Please, also check if these links can help you solve your problem:

How to set up Qt Creator to cross compile for embedded Linux | Toradex Developer Center.

Thank you @ToradexAI :smiley:

suggestion 3 did the trick.
In tasks.json I added "--user=${userid}:${groupid}" in the following two tasks:

{
  "label": "build-configure-arm64",
  "hide": true,
  "command": "DOCKER_HOST=",
  "type": "shell",
  "args": [
      "docker",
      "run",
      "--rm",
      "--user=${userid}:${groupid}",
      "-v",
      "${workspaceFolder}:${config:torizon_app_root}",
      "cross-toolchain-arm64-uv-smart-hvac-server",
      "cmake",
      "-DCMAKE_BUILD_TYPE=Debug",
      "-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++",
      "-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc",
      "-Bbuild-arm64"
  ],
  "problemMatcher": [
      "$gcc"
  ],
  "icon": {
      "id": "flame",
      "color": "terminal.ansiYellow"
  },
  "dependsOrder": "sequence",
  "dependsOn": [
      "build-container-image-sdk-arm64"
  ]
}

and

{
  "label": "build-debug-arm64",
  "detail": "Build a debug version of the application for arm64 using\nthe toolchain from the SDK container.",
  "command": "DOCKER_HOST=",
  "type": "shell",
  "args": [
      "docker",
      "run",
      "--rm",
      "--user=${userid}:${groupid}",
      "-v",
      "${workspaceFolder}:${config:torizon_app_root}",
      "cross-toolchain-arm64-uv-smart-hvac-server",
      "cmake",
      "--build",
      "build-arm64",
      "--parallel",                
      "-j"                
  ],
  "problemMatcher": [
      "$gcc"
  ],
  "icon": {
      "id": "flame",
      "color": "terminal.ansiYellow"
  },
  "dependsOrder": "sequence",
  "dependsOn": [
      "build-configure-arm64"
  ]
}

To use the variables userid and groupid I added the following two inputs:

{
    "id": "userid",
    "type": "command",
    "command": "id",
    "args": ["-u"]
},
{
    "id": "groupid",
    "type": "command",
    "command": "id",
    "args": ["-g"]
}

Best Regards
Uwe

Hello @buw3,

Glad the AI was able to help you out.

Best regards
Collin