Build error Toolchain doesn't support std::filesystem with nor without -lstdc++fs


I am building RPI4 image with branch 23.05.03 on ubuntu 18.04 machine. I got the error:

-- Performing Test std_atomic_without_libatomic
-- Performing Test std_atomic_without_libatomic - Success
-- Performing Test std_filesystem_without_libfs
-- Performing Test std_filesystem_without_libfs - Failed
-- Performing Test std_filesystem_with_libfs
-- Performing Test std_filesystem_with_libfs - Failed
CMake Error at cmake/StdFilesystem.cmake:22 (message):
  Toolchain doesn't support std::filesystem with nor without -lstdc++fs
Call Stack (most recent call first):
  cmake/StandardSettings.cmake:57 (include)
  CMakeLists.txt:70 (include)

-- Configuring incomplete, errors occurred!
Makefile:27: recipe for target '/media/wu/openwrt/build/openwrt/build_dir/host/ccache-4.8.1/.configured' failed
make[3]: *** [/media/wu/openwrt/build/openwrt/build_dir/host/ccache-4.8.1/.configured] Error 1
make[3]: Leaving directory '/media/wu/openwrt/build/openwrt/tools/ccache'

any advice?

Can you try building OpenWrt on a more recent version of Ubuntu? 18.04 is only receiving security updates at this point. You don't need the latest version, I've successfully built OpenWrt on 22.04.

will try to upgrade ubuntu. However, it worked when I build 23.05.02 image

Upgraded to ubuntu 22.04, seems ok building a test image with config.buildinfo downloaded from

Now I need select the additional packages to make new image for flashing. I have .config file from earlier build(22.03.4), which has all selected packages. Can I use this file to build? Will image builder automatically correct the potential problems e.g. removing non-existing packages, changed dependancy etc...?