Qt: character encoding not found

Hello,

I’m building a custom yocto image for the Verdin iMX8MM that is based on torizon-minimal and contains a Qt6 application.

When starting this application I get the following warning about a missing character encoding:

Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.

I tried to solve this problem by adding the following to my image

GLIBC_GENERATE_LOCALES = "de_DE.UTF-8 en_US.UTF-8"
IMAGE_LINGUAS = "de-de en-us"

but the warning remains.

What else do I have to do?

Best regards,
Markus

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello Markus,

Thank you for your detailed question.

The warning appears because your environment defaults to the “C” locale, which is not UTF-8. Even though you’ve added GLIBC_GENERATE_LOCALES and IMAGE_LINGUAS, this only controls which locales are generated and included in your image—it does not set the system’s default locale at boot/runtime.

Here’s how you can address the issue:

1. Ensure Locale Files Are Deployed

First, confirm that your image actually includes the generated locale files for UTF-8 (e.g., /usr/lib/locale/en_US.UTF-8). Verify this after flashing your image.

2. Set Default Locale via System Environment

You need to set environment variables in your system so that the shell and applications launch with the desired UTF-8 locale. Commonly, this is done by setting variables in /etc/profile, /etc/environment, or a drop-in file in /etc/profile.d/.

For Yocto, you can achieve this in your image recipe (.bb or .bbappend) with an install command, for example:

do_install_append() {
    echo 'export LANG=en_US.UTF-8' >> ${D}${sysconfdir}/profile.d/qt6-locale.sh
    echo 'export LC_ALL=en_US.UTF-8' >> ${D}${sysconfdir}/profile.d/qt6-locale.sh
}

This example sets the default locale to UTF-8 for all shell sessions. Adjust the locale as needed (e.g., use de_DE.UTF-8 for German).

3. Additional Run-time Test

After booting, check the active locale:

locale

You should see values like en_US.UTF-8 or de_DE.UTF-8 for LANG and LC_ALL. If they still show C or POSIX, your environment variables were not set properly.

If you continue to have issues, reference the Yocto Project documentation for details on locale configuration:
Yocto Project: Build a Reference Image

And for general Yocto setup steps:
Yocto Project Setup

Let me know if you need further guidance!

Best regards,
Toradex AI Assistant

Hello @Mowlwurf,

Just to confirm, was the response above from the AI enough to solve this issue?

Best Regards,
Bruno

Hello @bruno.tx,

yes, the answer from the AI gave me the right hint with the file under /etc/profile.d.

However, the code example was not quite correct. A do_install:append() does not work in an image recipe. Even a ROOTFS_POSTPROCESS_COMMAND did not work either, strangely enough.

I have created my own recipe with the two lines of code, which I add to IMAGE_INSTALL in my image recipe:

DESCRIPTON = "set character encoding for all shells and applications"
LICENSE = "CLOSED"

PR = "r0"

do_install() {	
	install -d ${D}${sysconfdir}/profile.d/
    echo 'export LANG=de_DE.UTF-8' 		>> ${D}${sysconfdir}/profile.d/locale.sh
    echo 'export LC_ALL=de_DE.UTF-8' 	>> ${D}${sysconfdir}/profile.d/locale.sh
}

Best regards,
Markus

Hello @Mowlwurf,

That is great to know.
Thanks for sharing the solution.

Best Regards,
Bruno