1

I'm trying to use Mathematica's Compile[] function to speed up some of my computations:

Compile[<some_code>, CompilationTarget -> "C", RuntimeOptions -> "Speed"];

However, whenever I try to do so, I get the following error:

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

When I execute the following code:

Needs["CCompilerDriver`"]
CCompilers[]

I get

{}

And when I execute

CCompilers[Full]

I get

{{"Name" -> "Intel Compiler", 
"Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler, 
"CompilerInstallation" -> None, 
"CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler", 
"Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler, 
"CompilerInstallation" -> None, "CompilerName" -> Automatic}}

I am using Mathematica 11 and Windows 11. What I've tried so far:

  • Installed gcc on my computer and configured the PATH correctly. When I type gcc on the command line, I get the expected output.
  • Installed Visual Studio 2022 C++ development tools.
  • Installed Visual Studio 2022 Build Tools for C/C++ development.
  • Read the documentations (both the official one and the one linked below).

What more can I do?

Klangen
  • 1,009
  • 5
  • 14
  • 2
    maybe useful: https://mathematica.stackexchange.com/a/5593/9490 – Jason B. Jan 01 '23 at 14:49
  • You have to tell Mathematica where your compiler is. I use the MinGW compiler so after the Needs command I execute $CCompiler = {"Compiler" -> CCompilerDriverMinGWCompilerMinGWCompiler, "CompilerInstallation" -> "C:\\Program Files\\CodeBlocks\\MinGW\\bin"}; which give the location of the MinGW c-compiler bin file on my machine. – josh Jan 01 '23 at 15:37
  • Probably the first link should solve it. https://mathematica.stackexchange.com/questions/41682/c-compilation-not-working-with-visual-studio-2013 https://mathematica.stackexchange.com/questions/6897/what-compilers-are-suitable-for-compilationtarget-c – Tetrasreal Jan 04 '23 at 00:37

0 Answers0