1
$\begingroup$

I have been trying to compile some functions in mathematica with target C for speed.

basically when I try:

c = Compile[ {{x, _Real}, {n, _Integer}},
    Module[ {sum, inc}, sum = 1.0; inc = 1.0; 
    Do[inc = inc*x/i; sum = sum + inc, {i, n}]; sum], 
   CompilationTarget -> "C"];

I get the following error:

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

But it looks like Mathematica is already recognizing my C compiler infact If I try:

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

I get:

CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler

{{"Name" -> "Visual Studio", 
  "Compiler" -> 
   CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
  "CompilerInstallation" -> 
   "C:\\Program Files (x86)\\Microsoft Visual Studio 11.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}}

{{"Name" -> "Visual Studio", 
  "Compiler" -> 
   CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
  "CompilerInstallation" -> 
   "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0", 
  "CompilerName" -> Automatic}}

Am I doing something completely wrong? Probably yes, Anybody has an answer?

Thank you in advance

$\endgroup$
9
  • 1
    $\begingroup$ your code works for me using GCC. this suggests its a configuration problem with your compiler or how it interacts with mathematica. $\endgroup$
    – chris
    Commented Apr 1, 2015 at 17:12
  • $\begingroup$ Thanks, also for the edit! you are probably right because in my mac OSX the code works just fine. I am wondering if there is a way of specifying one particular compiler. $\endgroup$
    – Raf
    Commented Apr 1, 2015 at 17:18
  • $\begingroup$ You have the Windows SDK installed? reference.wolfram.com/language/CCompilerDriver/tutorial/…. Also you can set things like $CCompiler = {"Compiler" -> GenericCCompiler, "CompilerInstallation" -> "C:/MinGW-w64", "CompilerName" -> "x86_64-w64-mingw32-gcc.exe"}; $\endgroup$ Commented Apr 1, 2015 at 17:18
  • 1
    $\begingroup$ Try evaluating Compiler`$CCompilerOptions = {"ShellOutputFunction" -> Print} to see the compiler output $\endgroup$ Commented Apr 1, 2015 at 18:06
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because it looks like a system configuration issue - the OP upgraded to V10 and no longer had any problems, so any answer is unlikely to benefit other users. $\endgroup$ Commented Sep 28, 2015 at 8:33

0

Browse other questions tagged or ask your own question.