0
$\begingroup$

I want to use Compile. I got the following error message:

CreateLibrary::nocomp: A C compiler cannot be found on your system. Please consult the documentation to learn how to set up suitable compilers.

Compile::nogen: A library could not be generated from the compiled function.

I've already installed MinGW in the path: D:\MinGW, which has a C compiler from what I read.

So, what step can I take to make Mathematica to recognize the C Compiler?

This may also be relevant:

In[1]:= Needs["CCompilerDriver`"]

In[2]:= CCompilers[Full]

Out[2]= {{"Name" -> "Intel Compiler", 
  "Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler, 
  "CompilerInstallation" -> None, 
  "CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler", 
  "Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler, 
  "CompilerInstallation" -> None, "CompilerName" -> Automatic}}
$\endgroup$
  • $\begingroup$ I suggest you use Visual Studio unless you have a good reason not to. It is the recommended compiler for Windows and works with Mathematica without further configuration. If all you need is to make Compile work a bit faster, then there is no reason to use anything else than Visual Studio. $\endgroup$ – Szabolcs Aug 23 at 17:38
  • $\begingroup$ @Szabolcs so, since I'm using Win7, I downloaded SDK 7.1 . However, my mathematica V12 isn't working automatically... Is it because I did something like $CCompiler={"Compiler"->GenericCCompiler, "CompilerInstallation"->"C:\\Program Files\\mingw-w64\\mingw64\\bin", "CompilerName"->"gcc.exe", "ShellOutputFunction"->Print} before? $\endgroup$ – An old man in the sea. Aug 23 at 20:23
  • $\begingroup$ I suggest installing "Visual Studio Build Tools" and restarting Mathematica (do not change the value of $CCompiler!) Microsoft keeps changing the download pages, so I can't find where it is right now ... Last time I used Build Tools 2015, but I believe newer ones should work fine with Mathematica 12.0. $\endgroup$ – Szabolcs Aug 23 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.