This is both a comment, too long to be posted as a comment, on the previous answer, and another answer. The reason for posting is that the steps that I had to do to get MinGW-64 working on my computer are a little bit different and simpler than the steps given by Leon.
Obviously, the first step is to get MinGW-64. I was unable to do this on win-builds.org, but just as in this question, I downloaded from sourceforge.net the executable mingw-w64-install.exe. I ran it with the settings Architecture: x86-64 and Threads: win32. That took about 15 minutes. The progress bar was much faster at the end than at the beginning. Inside the map mingw-w64, two levels down, there is a map mingw64. I copied this map to C:\ and renamed it as MinGW-64. Now we are the situation described in the tutorial "Specific Compilers" under the head "MinGW for 64-Bit Targets". So I tried the greeter test mentioned there:
greeter=CreateExecutable[StringJoin[
"#include <stdio.h>\n",
"int main(){\n",
" printf(\"Hello MinGW-w64 world.\\n\");\n",
"}\n"],
"hiworld","Compiler"->GenericCCompiler,"CompilerInstallation"->"C:\\MinGW-64\\bin","CompilerName"->"x86_64-w64-mingw32-gcc.exe"]
(*C:\Users\Fred Simons\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\hiworld.exe*)
It worked immediately. (Observe that there are no spaces in the path to MinGW-64, and that we may leave out '\bin'. See also my comment at the end of this answer.)
Import["!\""<>greeter<>"\"","Text"]
(* Hello MinGW-w64 world. *)
This works as well. Next, as in the tutorial, I defined $CCompiler:
$CCompiler = {"Compiler"->GenericCCompiler, "CompilerInstallation"->"C:\\MinGW-64\\bin","CompilerName"->"x86_64-w64-mingw32-gcc.exe"};
f = Compile[{x}, Sqrt[1+x^2], CompilationTarget->"C"];
f[1]
(* 1.41421 *)
So everything works fine. Even better, it behaves like a correct installation of a C-compiler, without having placed anything in an init.m file or having created system variables; in every session of Mathematica it works immediately.
A side remark. Actually, I described my installation of MinGW in Mathematica 10. When I started the testing of Mathematica 11, it did not work any more. I had a very good support of WRI. The reason was that in the map \SystemFiles\FrontEnd\Binaries\Windows-x86-64 in the installation directory there was a file libwinpthread-1.dll, which is missing in the map for Mathematica 11. Copying this file from Mathematica 10 to Mathematica 11 solved the problem. In Mathematica 11.0.0 this file seems to be not needed anymore.
After all, installing the MinGW compiler on my computer turned out to be simple. It takes 'only' 421 MB of memory, while an installation of Windows Visual Studio takes at least about 2GB. I hate my computer to be polluted with a lot of software that I do not need. But my installation seems to have a problem: it is not recognized by Mathematica as an installed compiler. CCompilers[]
returns an empty list and SystemInformation[]
tells me that there are no C-compilers installed, despite the fact that I have it working. I have no idea if this is a serious problem. It works flawless for already a year, both in Mathematica 10 and in Mathematica 11.