4
$\begingroup$

Win7-64 bit. Visual Studio 2015 Community Edition

I am unable to get MMA to recognise the VS Compiler to compile functions to C.

I had installed VS Studio and the C++ compiler (and test compiled the calculator demo); I reinstalled .NET Framework 4.6.1 afterwards and let it make any repairs necessary.

I have followed the instructions in the answer to question 41682 and in the community group, i.e. I have edited VisualStudioCompiler.m to add "2015" to the versions and the installpath reference to, so those lines now read CORRECTION changed {"2015","..} to {"2015", "...} in .m file - made no difference.

$VisualStudioVersions = {"2015","2013", "2012", "2010", "2008", "2005"}

and CORRECTION^2 changed "InstallPath" to "installPath" in .m file - FIXED IT.

installPath["2015"] := installPathFromEnvironment["VS140COMNTOOLS"]

The file was saved to the desktop and copied back to the MMA folder successfully.

I have checked the environment variable in Control Panel -> System -> Advanced -> Environment Variables and there is a variable VS140COMNTOOLS with the value "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\"

I quit and restarted MMA but after executing

Needs["CCompilerDriver`"]
CCompilers[Full]

MMA still can't find the compiler; I still get as output

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

VS Studio was "registered" (So removing the "trial" period of free use).

I have also just restared the whole PC and CCompilers[Full] returns the same result.

Is anyone able to offer further advice?

$\endgroup$

closed as off-topic by Szabolcs, Wjx, Michael E2, gwr, user31159 Oct 1 '16 at 12:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Wjx, Michael E2, gwr, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ I may be wrong, but I am not confident that Mathematica supports Visual Studio 2015, and I've personally had a hell of a time (unsuccessfully) trying to connect to compilers not on that page. See reference.wolfram.com/language/CCompilerDriver/tutorial/…. $\endgroup$ – user6014 Sep 30 '16 at 16:12
  • $\begingroup$ The answer by @bcolleti (#2) in the first referenced question specifically addresses VS2015, so it ought to work. I suppose, if it were "oficially" supported there would be no need to edit the .m file, but I infer that those who know better seem to think it works regardless. $\endgroup$ – Julian Moore Sep 30 '16 at 16:16
  • $\begingroup$ PS That list looks very old, and Wolfram merely says what MMA has been tested with. Given that the answers i referred to quote VS 2013 AND 2015 I guess it could do with updating. $\endgroup$ – Julian Moore Sep 30 '16 at 16:22
  • $\begingroup$ @szabolcs et al - Yes you are right, it did arise that way, but don't many questions? (not complaining though) Isn't the issue really down to the fact that I found the fault myself? If anyone else had done, it would have been like any other "simple mistake". Your call though. $\endgroup$ – Julian Moore Oct 1 '16 at 18:59
5
$\begingroup$

I can now confirm that the instructions in the answer to question [41682][1] and in the [community group][2] work.

CAUTIONS

  1. VisualStudioCompiler.m cannot be saved back directly to its orignal location - it must be saved elsewhere and copied back (or possibly change the folder permissions). Be careful that MMA doesn't change the filetype on save.

  2. Pay careful attention to character cases - my problem was entirely down to typing "InstallPath" where I should have typed "installPath" (Lower case initial "i"). There was no warning about this presumably meaningless instruction from MMA on the execution that needed VisualStudioCompiler.

On making these corrections, quitting and restarting MMA a function compiled to C and executed.

VisualStudioCompiler.m should be modified to contain

$VisualStudioVersions = {"2015", "2013", "2012", "2010", "2008", "2005"}

and

installPath["2015"] := installPathFromEnvironment["VS140COMNTOOLS"]

Provided VS Studio 2015 is correctly setup, it should then work.

Afterwards,

Needs["CCompilerDriver`"]
CCompilers[Full]

should then show something similar to this, wrt VS 2015...

{{"Name" -> "Visual Studio", 
  "Compiler" -> 
   CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
  "CompilerInstallation" -> 
   "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0", 
  "CompilerName" -> Automatic}, {"Name" -> "Intel Compiler", 
  "Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler, 
  "CompilerInstallation" -> None, 
  "CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler", 
  "Compiler" -> CCompilerDriver`GenericCCompiler`GenericCCompiler, 
  "CompilerInstallation" -> None, "CompilerName" -> Automatic}}
$\endgroup$

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