ld unable to find iostreams functions under MSYS2

I don’t, and setting it doesn’t seem to change the behavior of cmake. But in the MSYS2 MinGW shell /mingw64/bin/cc.exe -v indicates that it should be the same compiler. Looking at the compiler invocation I can’t see anything that would change behavior.