Build Error with GCC 9.X
With GCC 9.X or older version, it shows compile errors as below.
| update-mime-database.cpp:(.text.startup+0x1a6): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
| update-mime-database.cpp:(.text.startup+0x1d9): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
| update-mime-database.cpp:(.text.startup+0x261): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
| update-mime-database.cpp:(.text.startup+0x298): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
| update-mime-database.cpp:(.text.startup+0x53b): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
| update-mime-database.cpp:(.text.startup+0x543): undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
| update-mime-database.cpp:(.text.startup+0x703): undefined reference to `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)'
| update-mime-database.cpp:(.text.startup+0x7c4): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
| update-mime-database.cpp:(.text.startup+0x827): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
| update-mime-database.cpp:(.text.startup+0x82f): undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const'
| update-mime-database.cpp:(.text.startup+0x924): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
| update-mime-database.cpp:(.text.startup+0x953): undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
| update-mime-database.cpp:(.text.startup+0xb80): undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
It needs to add extra link argument in meson.build to link libstdc++fs correstly.
From 9a2d0a3514610fb197c6de49e7ab84657b5b94b5 Mon Sep 17 00:00:00 2001
From: Potin Lai <potin.lai@quantatw.com>
Date: Wed, 29 Nov 2023 13:54:36 +0800
Subject: [PATCH 1/1] fix build error for gcc 9.X
Upstream-Status: Submitted
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
---
meson.build | 1 +
1 file changed, 1 insertion(+)
diff --git a/meson.build b/meson.build
index ecc012f..9baf74c 100644
--- a/meson.build
+++ b/meson.build
@@ -6,6 +6,7 @@ project('shared-mime-info',
default_options : ['cpp_std=c++17']
)
+add_project_link_arguments('-lstdc++fs', language : 'cpp')
config = configuration_data()
i18n = import('i18n')
--
2.31.1