Howto BuildRequire a higher gcc version for #include <filesystem>? Or else?

Hello, I am trying to build a c++ based package on obs for 15.4, 15.5, Tumbleweed, which includes <filesystem>. Unfortunately this seems to be standard from gcc-c++>=11 on, only. BuildRequires: gcc>=11 results in "nothing provides gcc>=11". I have also tried "gcc >=11", and BuildConflicts: gcc however, this completely breaks. I have tried "gcc11-c++" which installs, but is not used in the build. Is it possible to switch to a higher gcc version via spec file alone? Or is it possible to compile this with gcc<11 by means of some CC flags? I have searched on the net extensively, without result. I would appreciate a pointer to any information that could help. Thank you in advance, Alex

On Saturday 2023-11-11 10:57, Alexander Krupp wrote:
Hello,
I am trying to build a c++ based package on obs for 15.4, 15.5, Tumbleweed, which includes <filesystem>. Unfortunately this seems to be standard from gcc-c++>=11 on, only.
BuildRequires: gcc>=11
preamble %if 0%{?suse_version} && 0%{?suse_version} < 1599 BuildRequires: gcc11 (and/or gcc11-c++) %endif ... %build %if 0%{?suse_version} && 0%{?suse_version} < 1599 export CC=gcc-11 CXX=g++-11 %endif New versions are added as time passes, we might be past 11 already.

On Nov 11 2023, Jan Engelhardt wrote:
%if 0%{?suse_version} && 0%{?suse_version} < 1599 BuildRequires: gcc11 (and/or gcc11-c++) %endif
Alternatively, this could use %{gcc_version} < 11. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."

On Monday 2023-11-13 09:28, Andreas Schwab wrote:
On Nov 11 2023, Jan Engelhardt wrote:
%if 0%{?suse_version} && 0%{?suse_version} < 1599 BuildRequires: gcc11 (and/or gcc11-c++) %endif
Alternatively, this could use %{gcc_version} < 11.
That is not defined everywhere. (On the off-chance you are building outside SUSE OBS for any particular reason.) $ rpm --eval %gcc_version %gcc_version
participants (3)
-
Alexander Krupp
-
Andreas Schwab
-
Jan Engelhardt