The main issue you have here is that compiler.find_library returns a dep object, i.e. it is already a dependency. As such, it cannot occur in the link_whole argument for declare_dependency, which accepts only lib values, i.e. static/shared libraries buildable by meson.