From 9fd172f496ddf3794dda45e8b7c3f713418be970 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 26 May 2021 02:44:29 +0300 Subject: android: Fix file system library usage on gcc 7 and 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On gcc versions older than 9, the file system library, used by the Android camera HAL configuration file parser, is implemented in a separate static library. Furthermore, on gcc 7, it's provided in the std::experimental namespace. This breaks compilation of the HAL on gcc 7, and linking on gcc 8. Fix the compilation issue by conditionally including and creating a namespace alias in std, and the link issue by linking to libstdc++fs on gcc versions older than 9. The inclusion of is a bit of a hack, and when we'll start using the file system library in another compilation unit, we should then move all this to an internal helper to abstract the compiler version. Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- meson.build | 8 ++++++++ src/android/camera_hal_config.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/meson.build b/meson.build index 6626fa7e..2e7dffb7 100644 --- a/meson.build +++ b/meson.build @@ -76,6 +76,14 @@ if cc.get_id() == 'gcc' error('gcc version is too old, libcamera requires 7.0 or newer') endif + # On gcc 7 and 8, the file system library is provided in a separate static + # library. + if cc.version().version_compare('<9') + cpp_arguments += [ + '-lstdc++fs', + ] + endif + # gcc 7.1 introduced processor-specific ABI breakages related to parameter # passing on ARM platforms. This generates a large number of messages # during compilation with gcc >=7.1. Silence them. diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp index d15df2e3..f33ba269 100644 --- a/src/android/camera_hal_config.cpp +++ b/src/android/camera_hal_config.cpp @@ -6,7 +6,14 @@ */ #include "camera_hal_config.h" +#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE < 8 +#include +namespace std { +namespace filesystem = std::experimental::filesystem; +} +#else #include +#endif #include #include #include -- cgit v1.2.1