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

Here is what I did.


So, the output is


and this means that I have no compilers installed.

I tried


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

$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?


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).

  • $\begingroup$ MinGW 64 bit is troublesome and nontrivial to use with Mathematica. Why don't you just use the Microsoft compiler, which works out of the box? You can install the Windows SDK 7.1, and Mathematica will "just work" (I tested with v9 and v10). If you install the latest free version of Visual Studio, Mathematica version 10 and later will "just work". Asking about how to make it work with MinGW 64 bit is still a valid question but expect to spend time on it and consider what you get in return for that time. $\endgroup$
    – Szabolcs
    Apr 7, 2015 at 20:25
  • $\begingroup$ @Szabolcs Thanks for your reply. I will try SDK 7.1. $\endgroup$
    – Artem
    Apr 7, 2015 at 20:26
  • 1
    $\begingroup$ @Szabolcs The only reason I started with MinGW is that three-four years ago it took me literally 10 minutes to start it working with one of the previous versions. $\endgroup$
    – Artem
    Apr 7, 2015 at 20:29
  • 2
    $\begingroup$ I would recommend to install Windows SDK 7.1 with just the components you need (compiler). I do this to save time, but it does take considerably more disk space than MinGW. I also used to use MinGW in the past. I should mention that I don't use Windows often any more so I don't know what is the latest thing that works well, only that the Windows SDK 7.1 worked for me in the past. $\endgroup$
    – Szabolcs
    Apr 7, 2015 at 20:32
  • 1
    $\begingroup$ @Szabolcs Possible duplicates?: (5487), (55034) $\endgroup$
    – Mr.Wizard
    May 5, 2015 at 0:36

1 Answer 1


Even though it's quite late to reply, but I need to point out that the culprit is the white space between Program Files. If you set the installing path without white spaces, then it will just work.

I accidentally find the solution by append an option "ShellOutputFunction"->Print to $CCompiler. from this answer.

 "CompilerInstallation"->"C:\\Program Files\\mingw-w64\\mingw64\\bin",

and compile the following code from the documentation

Compile[ {{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"]

I get an warning message like

C:\Program' is not an internal or external command nor is it a running program or batch file.

This clearly shows the solution I mentioned at the beginning. Hope it helps.

  • 1
    $\begingroup$ Sorry, I have VisualStudio free and I can not use compile, like if there is not compiler, I tried with your help but does not find any, thanks $\endgroup$ Jul 4, 2018 at 20:44
  • $\begingroup$ @AnxonPués My answer is for the MinGW gcc compiler. Based on my experience, Mathematica automatically supports VisualStudio. If you have any trouble, you may find the other answers on this website helpful. $\endgroup$
    – luyuwuli
    Jul 4, 2018 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.