[libcamera-devel] [PATCH 2/2] android: Fix file system library usage on gcc 7 and 8
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed May 26 10:16:32 CEST 2021
Hi Laurent,
Thanks for your work.
On 2021-05-26 03:08:55 +0300, Laurent Pinchart wrote:
> 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
> <experimental/filesystem> 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 <experimental/filesystem> 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 <laurent.pinchart at ideasonboard.com>
This solves my issues, thanks!
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> meson.build | 8 ++++++++
> src/android/camera_hal_config.cpp | 7 +++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 6626fa7ed154..2e7dffb70acc 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 d15df2e30c2c..f33ba26935da 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 <experimental/filesystem>
> +namespace std {
> +namespace filesystem = std::experimental::filesystem;
> +}
> +#else
> #include <filesystem>
> +#endif
> #include <stdio.h>
> #include <stdlib.h>
> #include <string>
> --
> Regards,
>
> Laurent Pinchart
>
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list