# How do I get Mathematica to recognize a C compiler on a 64-bit Windows machine?

Mathematica does not recognize any C compiler on my computer. I run Mathematica 8.0.4.0 on Windows 7. I've tried to make sure various C compilers are installed on my computer, but I'm not sure how to get Mathematica to recognize the installation.

If the compiler is installed correctly, should Mathematica automatically recognize it, or do I have to point Mathematica to a very specific folder to find it?

I edited this post according to some of the comments below by @Szabolcs and @. I've been through https://stackoverflow.com/a/6549505/695132 , and step 2 appears to fail.

I've already been to http://forums.wolfram.com/mathgroup/archive/2011/Nov/msg00024.html, and I installed Microsoft Windows SDK v7.1 for Windows 7 and .NET Framework 4 for xI64. http://www.microsoft.com/en-us/download/details.aspx?id=8442

I also got the Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1: http://www.microsoft.com/download/en/details.aspx?id=4422

Please forgive me for not knowing how to check to see if the compiler is working. I simply don't even know where to start with Visual Studios and all that.

Needs["CCompilerDriver"]
DefaultCCompiler[]
CCompilers[Full]
CCompilers[]


gives the following output:

$Failed {} {{"Name" -> "Intel Compiler", "Compiler" -> CCompilerDriverIntelCompilerIntelCompiler, "CompilerInstallation" -> None, "CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler", "Compiler" -> CCompilerDriverGenericCCompilerGenericCCompiler, "CompilerInstallation" -> None, "CompilerName" -> Automatic}}  I get the following error when I try to compile: CreateLibrary::instl: The compiler installation directive "CompilerInstallation" -> C:\Program Files (x86)\Microsoft Visual Studio 10.0\SDK does not indicate a usable installation of Visual Studio. >>  My question is similar to this question thread, but I don't have enough reputation to ask on that thread. https://stackoverflow.com/questions/6537457/gcc-installed-mathematica-still-wont-compile-to-c I also have "gcc" show up in a search in various folders under Python27 and MinGW, but Mathematica doesn't seem to know about it. I don't care which compiler I use; I just want an easy installation. I spent a day trying all sorts of stuff mentioned on various forums, but nothing is working. Why does Mathematica not come out of the box with a working compiler? • You should not change$CCompilers or set anything else special. Please restart Mathematica, and evaluate Needs["CCompilerDriver"]; CCompilers[] (in a fresh kernel) and post what it returns. Also try  Compile[x, x, CompilationTarget -> "C"]. Actually iy would be best if you went through those 4 steps I posted [here](http://stackoverflow.com/a/6549505/695132) and posted the results. Again: don't change things like \$CCompiler before testing!! Can you start a Windows SDK Command Prompt and test manually that the compiler works (cl.exe)? – Szabolcs May 13 '12 at 6:38
• If you have a 64-bit system, you have two free choices: 1. The 64 bit command line compiler from the Windows 7 SDK. This should 'just work' after installation. (It is not necessary to install Visual Studio, just the compiler from the SDK!!) 2. a 64-bit MinGW: this will require manual setup using the generic compiler driver (there are step by step instructions specifically for this toolchain in the docs), and is a lot more trouble to get working. – Szabolcs May 13 '12 at 6:40
• @Szabolcs although MinGW-w64 gcc can be made to work (I use it, for example) the instructions in the docs aren't sufficient; proper support needs extra work that isn't documented anywhere officially. If the goal here is easy installation, Visual C++ 2010 is definitely the best option. I posted some step-by-step instructions here. (I won't claim this is the only way, but to me it seemed like the easiest route.) – Oleksandr R. May 13 '12 at 6:50
• @Oleksandr I agree, that's why I said it's a lot of trouble. I used MinGW-w64 for a while as well, but I don't remember if the sintructions in the docs were sufficient or not. I remember I set it up based on those though. – Szabolcs May 13 '12 at 6:59
• This question might be retitled to indicate it is specific to Windows 64-bit, if that is the intent. Compiler setup is typically much simpler on Linux, MacOS, and even on 32-bit Windows where Cygwin and MinGW pretty much just work. – Joel Klein May 15 '12 at 19:02

First, be sure to read the Specific Compilers section of the CCompilerDriver User Guide. This is the official place where the nuts and bolts of using external C compilers is discussed.

In that section, "Visual Studio Express and 64-Bit Targets" is where compilation on 64-bit Windows is discussed.

Some things to check when setting up:

• Be sure to install .NET Framework 4 before Windows SDK 7.1. Without this, the Windows SDK installer may (if you don't have it) give a warning about this, and the Visual C++ component will be grayed out.

• In the install wizard for the Windows SDK, be sure any components that say "Visual C++" are selected for installation.

If you're not sure if you have the .NET Framework 4, you can try running the Windows SDK 7.1 installer and look carefully for a warning dialog. If you don't get a dialog warning that .NET Framework is not detected, and the Visual C++ component is selectable for installation, then you may proceed with installing just the Windows SDK.

I can confirm that you don't need to install Visual Studio Express first, you can get away with installing only the .NET Framework 4 (if needed) and then the Windows SDK.

Edited to add: In answer to "If the compiler is installed correctly, should Mathematica automatically recognize it, or do I have to point Mathematica to a very specific folder to find it?", for Visual Studio it is automatically recognized through an environment variable or the registry. Of the compilers that are directly supported, as opposed to a "Generic" C compiler, they are all automatically detected in some form, depending on the specifics of the compiler.

• This did it! Without uninstalling Windows SDK (again), I simply installed the .NET Framework 4 link, restarted my computer, and then now it works. CCompilers[] now gives {{"Name" -> "Visual Studio", "Compiler" -> CCompilerDriverVisualStudioCompilerVisualStudioCompiler, "CompilerInstallation" -> "c:\\Program Files (x86)\\Microsoft Visual Studio 10.0", "CompilerName" -> Automatic}} Apparently, this link didn't install .Net Framework 4. – Paul May 15 '12 at 21:15
• Yes, it's confusing that something called "Windows SDK for Windows 7 and the .NET Framework 4" does not install .NET Framework 4. – Joel Klein May 16 '12 at 13:54
• Yes. I reinstalled the .Net Framework, it also works without reboot. So the .Net Framework installer in Intel C Compiler has some problems. After install the ICC, you must reinstall the .Net Framework in order to help Mathematica recognize the compiler. – Nam Nguyen Feb 5 '14 at 16:01
• I followed exactly the same way as you suggested (first install .NET Framework 4 then install Windows SDK), but still got the same problem in Paul's post. My system: Win7 64 bit + Mathematica 11.2. Could you help me about this problem? – Wilhelm Feb 23 '18 at 4:22
• I installed the Microsoft Visual C++ 2010 Express, although I already have Microsoft Visual Studio 2008. This fixed my issue. – Wilhelm Feb 23 '18 at 7:03