我的操作系统是 Windows 7 64 位。我安装了 Microsoft C++ 2008 Express 版和 Intel C++ Compiler v11.1 x86 版。
现在我可以在 Mathematica 中成功编译 x86 C 代码,例如
In[1]:= Needs["CCompilerDriver`"]
In[2]:= greeter = CreateExecutable[StringJoin["#include <stdio.h>\n", "int main(){\n", " printf(\"Hello world.\\n\");\n", "}\n"], "hiworld",
"Compiler" -> CCompilerDriver`IntelCompiler`IntelCompiler,
"CompilerInstallation" -> "C:\\Program Files (x86)\\Intel\\Compiler\\11.1\\072\\",
"CompilerName" -> Automatic, "TargetSystemID" -> "Windows"]
Out[2]= "C:\\...\\AppData\\Roaming\\Mathematica\\\
SystemFiles\\LibraryResources\\Windows-x86-64\\hiworld.exe"
但未能用于CompilationTarget -> "C"
编译这样的函数
In[3]:= f = Compile[{x, y}, Sqrt[x^2 + y^2], CompilationTarget -> "C"]
During evaluation of In[3]:= LibraryFunction::libload: The function compiledFunction5 was not loaded from the file C:\\...\AppData\Roaming\Mathematica\ApplicationData\CCompilerDriver\BuildFolder\vax-5844\compiledFunction5.dll. >>
During evaluation of In[3]:= Compile::nogen: A library could not be generated from the compiled function. >>
我想我需要指定一个默认值"TargetSystemID"-> "Windows"
,因为我的平台是 x64,但不知道如何在 Mathematica 中设置这样的选项。
我在这里错过了什么吗?
PS:最近不想安装Microsoft Visual Studio。