1

我试过了

    Needs["CCompilerDriver`IntelCompiler`"]

    greeter = CreateExecutable[StringJoin["#include <stdio.h>\n", "int main(){\n", "  printf(\"Hello world.\\n\");\n", "}\n"], "hiworld", "Compiler" -> IntelCompiler, "CompilerInstallation" -> "C:\\Program Files (x86)\\Intel\\Composer XE 2011 SP1\\bin\\ia32", "CompilerName" -> "icl.exe"]

但是得到一个错误:

    CreateExecutable::instl: The compiler installation directive "CompilerInstallation" -> C:\Program Files (x86)\Intel\Composer XE 2011 SP1\bin\ia32 does not indicate a usable installation of Intel Compiler. >>

编辑:

    In[776]:= CCompilers[Full]

    Out[776]= {{"Name" -> "Intel Compiler", "Compiler" -> IntelCompiler, "CompilerInstallation" -> None, "CompilerName" -> Automatic}, {"Name" -> "Generic C Compiler",  "Compiler" -> CompilerDriver`GenericCCompiler`GenericCCompiler,   "CompilerInstallation" -> None, "CompilerName" -> Automatic}}

    In[777]:= CCompilers[]
    Out[777]= {}

即使在我指定了它的位置之后,MMA 似乎也没有找到编译器。

我在这里错过了什么吗?

http://reference.wolfram.com/mathematica/CCompilerDriver/tutorial/SpecificCompilers.html#394172820

4

1 回答 1

2

从...开始

  Needs["CCompilerDriver`IntelCompiler`"]

检查您是否已安装IntelCompiler

   CCompilers[Full]

在我的情况下,我得到这样的东西:

 {{"Name" -> "Visual Studio", 
   "Compiler" -> CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
   "CompilerInstallation" -> "C:\\Program Files\\Microsoft Visual Studio 10.0", 
   "CompilerName" -> Automatic}, {...other compilers...},
   {"Name" -> "Intel Compiler", "Compiler" -> IntelCompiler, 
    "CompilerInstallation" -> None, "CompilerName" -> Automatic}}

并评估您的输入greeter=... ,错误消息就像您的情况一样。

CCompilers[Full]相反,从正确安装的输出中复制

In[1]:= Needs["CCompilerDriver`VisualStudioCompiler`"]
In[2]:= greeter =  CreateExecutable[ StringJoin["#include <stdio.h>\n", 
       "int main(){\n","  printf(\"Hello world.\\n\");\n", "}\n"], "hiworld", 
        "Compiler" -> VisualStudioCompiler, "CompilerInstallation" -> 
        "C:\\Program Files\\Microsoft Visual Studio 10.0", "CompilerName" -> "Automatic"]

Out[2]= "C:\\Users\\spindoctor\\AppData\\Roaming\\Mathematica\\\
             SystemFiles\\LibraryResources\\Windows\\hiworld.exe"

我得到那个可执行文件。

于 2012-01-18T14:29:17.760 回答