Many thanks for your help and your patience. Problem solved.
The problem was really on my compiler. Just now, it suddenly occurred to me that I should have cleaned up my environment variables including C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, etc. So I did that (also removed all reference to my own version of MinGW in PATH) and tried another time. This time all things worked fine. I suspect that TheIDE, although given the path of compilers, had still preferred the one in PATH, and that might be the real issue. By the way, MSVC also worked fine after my custom configuration.