I use buildroot to build Linux with busybox (without systemd). How to make en_US locale by default?
My buildroot config is similar to qemu_x86_defconfig but with extra
BR2_ENABLE_LOCALE_WHITELIST="en_US"
BR2_GENERATE_LOCALE="en_US"
After I try to start my hello world Qt app but I get noisy warning
Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
Qt depends on a UTF-8 locale, but has failed to switch to one.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.
Then I build locale tool. Let's check by locale
# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
But if I do
export LC_ALL=en_US.utf8 && ./myQt_app
Then works without warning. And locale
also can see en_US.utf8... How to export automatically?
There is no Unix standard for specifying a default locale.
systemd
uses /etc/locale.conf
to configure the default locale. You can manipulate this file at runtime with localectl
, or you can put it in the rootfs overlay.
For non-systemd init systems you have to cook up something yourself by setting the locale environment variables. You can put it in /etc/profile
, but that only works for programs that are started through a shell. If you start a program directly from inittab
there is no way to pass in environment variables, so you need a wrapper script.