How to solve this problem?

WARNING: Makefile 'package/feeds/packages/glib2/Makefile' has a build dependency on 'pcre2/host', which does not exist

more context is critical...

what version of OpenWrt are you trying to compile? Where did you obtain the source code?

You've got a warning there, but that's not an error.... are there other warnings or errors?

I used the 22.03.6 code from the openwrt official website and compiled it on ubuntu20.4. There are no other warnings.

If there are no other errors, does the compile work?

I haven't tried it yet. Doesn't this warning affect compilation?

Sometimes warnings will result in errors later. Other times they are just warnings but don't actually mean the compile will fail.

Okay, thank you, let me compile it and try it.

Good day,

I had the same warning message on my build machine, also Ubuntu 20, but seems to not affect my builds thus far.
Currently compiling OpenWRT 22.03 from Github.

linux:~/openwrt$ ./scripts/feeds install -a
WARNING: Makefile 'package/feeds/packages/glib2/Makefile' has a build dependency on 'pcre2/host', which does not exist
WARNING: Makefile 'package/feeds/kenzo/luci-app-wechatpush/Makefile' has a dependency on 'wrtbwmon', which does not exist
WARNING: Makefile 'package/feeds/packages/python-flask-babel/Makefile' has a build dependency on 'python-poetry-core/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a dependency on 'python3-editables', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a dependency on 'python3-pathspec', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a dependency on 'python3-trove-classifiers', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a build dependency on 'python-editables/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a build dependency on 'python-pathspec/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a build dependency on 'python-pluggy/host', which does not exist
WARNING: Makefile 'package/feeds/packages/python-hatchling/Makefile' has a build dependency on 'python-trove-classifiers/host', which does not exist
Installing all packages from feed packages.

Read the whole thread ?

If you don't use the packages, you can ignore the warnings. I get a bunch of them when building locally sometimes, due to commenting repos in the feeds.conf. Doesn't matter for you build process if you don't need the packages/dependencies.