我试过
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
答案 0 :(得分: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"
我得到了那个可执行文件。