Whatever WiFi library it’s compiling there it’s not the one from the Espressif32 core.
Remove any global WiFi library that you may have installed in <user home directory>\.platformio\lib
. And remove the .pio\libdeps
folder of the project. Then clean the project and build again.
If compilation is still not going through, do a “Advanced → Verbose Build” and post only the library dependency graph. Should show where this wrong WiFi library is hiding.