diff --git a/meson.build b/meson.build
index e86673dd5c0c..7dcd34d3e6b3 100644
--- a/meson.build
+++ b/meson.build
@@ -72,6 +72,10 @@ if cc.has_header_symbol('unistd.h', 'issetugid')
     config_h.set('HAVE_ISSETUGID', 1)
 endif
 
+if cc.has_header_symbol('locale.h', 'newlocale', prefix : '#define _GNU_SOURCE')
+    config_h.set('HAVE_NEWLOCALE', 1)
+endif
+
 if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE')
     config_h.set('HAVE_SECURE_GETENV', 1)
 endif
diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp
index 4a239427a4d9..ac3e1311995e 100644
--- a/src/libcamera/base/utils.cpp
+++ b/src/libcamera/base/utils.cpp
@@ -464,6 +464,8 @@ std::string toAscii(const std::string &str)
  * \a b
  */
 
+#if HAVE_NEWLOCALE
+
 namespace {
 
 /*
@@ -493,6 +495,8 @@ Locale cLocale("C");
 
 } /* namespace */
 
+#endif /* HAVE_NEWLOCALE */
+
 /**
  * \brief Convert a string to a double independently of the current locale
  * \param[in] nptr The string to convert
@@ -506,7 +510,15 @@ Locale cLocale("C");
  */
 double strtod(const char *__restrict nptr, char **__restrict endptr)
 {
+#if HAVE_NEWLOCALE
 	return strtod_l(nptr, endptr, cLocale.locale());
+#else
+	/*
+	 * If the libc implementation doesn't provide locale object support,
+	 * assume that strtod() is locale-independent.
+	 */
+	return strtod(nptr, endptr);
+#endif
 }
 
 } /* namespace utils */
