According to https://en.cppreference.com/w/cpp/filesystem :
Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs.
This is a backport of core#20744 [1/4]
https://github.com/bitcoin/bitcoin/pull/20744/commits/ffc89d1f21258553c0087b774a9ea1ce84139d4