I installed Visual Studio and then the command CCompilers[] in Mathematica 12.0 nicely gives:

{{"Name" -> "Visual Studio", "Compiler" -> CCompilerDriverVisualStudioCompilerVisualStudioCompiler, "CompilerInstallation" -> "C:\Program Files\Microsoft Visual Studio\2022\Community", "CompilerName" -> Automatic}}

However, the CompilationTarget -> "C" option still does not work:

f = Compile[{{h, _Real, 1}}, 
Block[{x, a, b}, x = h[[3]] Sin[h[[1]] h[[1]]]; 
a = x + Tan[x + h[[2]]]; b = 6.7 a; b], CompilationTarget -> "C"];

CreateLibrary::cmperr: Compile error: C:\Users\pantelidis\AppData\Roaming\Mathematica\ApplicationData\CCompilerDriver\BuildFolder\scc250a-19-10744\Working-scc250a-19-10744-8432-5\compiledFunction4.c(1): fatal error C1083: Cannot open include file: 'math.h': No such file or directory Compile::nogen: A library could not be generated from the compiled function.

If a possible solution involves editing an appropriate init.m file, I cannot find it in the Mathematica program folder. How do I get this to work? Thank you.

  • 2
    $\begingroup$ math.h is a standard library in "C". Therefore, the implementation of your "C" compiler seems to lack this header file. Or the compiler can not find it because of some problems with the path. $\endgroup$ Commented Apr 4, 2023 at 8:22

1 Answer 1


I found the mistake with the help of a friend. During installation I had unchecked the SDK installation option for Windows 11, since my system is Windows 10, but did not replace it with the Windows 10 SDK installation option, so they files were missing ... and even a simple C program could not run. Good news is that now we know that Mathematica finds Visual Studio right away and the whole process of installing Visual Studio and using its C compiler through Mathematica 12.0 is trivial. No special action is required.


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.