I remember using C compiler on my previous computers, and I never had any problems installing them. At this time, however, I failed to work through the instructions provided in Mathematica documentation.
I am using Windows 7 Home Premium 64 bits and Mathematica 9.0.1.0.
Here is what I did.
Needs["CCompilerDriver`"]
CCompilers[]
So, the output is
{}
and this means that I have no compilers installed.
I tried
CCompilers[Full]
the output was
{{"Name" -> "Intel Compiler",
"Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler,
"CompilerInstallation" -> None,
"CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler",
"Compiler" -> GenericCCompiler, "CompilerInstallation" -> None,
"CompilerName" -> Automatic}}
So here is my first question: Does this mean that my version of Windows and Mathematica would not support Visual Studio free compiler, since the name is not the list?
Next, I tried to install, following the instructions in the documentation center, 64 bit version of MinGW.
The description says
First, you need to acquire and install the binaries from http://mingw-w64.sourceforge.net. In order to use this variant of MinGW on a 64-bit system, look for "w64" or "Win64" in the name, not "w32" or "Win32". A typical file name is mingw-w64-bin_x86-64-mingw_20100414.zip.
However, there are no files like this anymore on the referenced site. I found a program mingw-w64-install.exe
and tried to use to install C compiler. And here is another question. This installation file allows choosing
- Version
- Architecture
- Threads
- Exception
- Built revision
Does it actually matter what to choose during the installation?
I installed the compiler using the default settings (I only switched from i686 to x86-64)and tried to execute
Needs["CCompilerDriver`GenericCCompiler`"]
$CCompiler = {"Compiler" -> GenericCCompiler,
"CompilerInstallation" -> "C:\\Program Files\\mingw-w64\\mingw64",
"CompilerName" -> "x86_64-w64-mingw32-gcc.exe"}
And after
f = Compile[{x, y}, Sqrt[x^2 + y^2], CompilationTarget -> "C"]
I got the error message
Compile::nogen: A library could not be generated from the compiled function. >>
Now my final question: Is there any simple way for me to find a free C Compiler for my version of Mathematica and install it on my machine?
Update:
It turns out that the simplest way is to go with Windows SDK 7.1, which can be downloaded here. Note that before installing it one needs to remove all olver version of Visual C++ Redistributable (anything that has 2010 and up). After installing SDK, Mathematica just works without any additional tweaks (I have to say that I ran just very simple examples).