我在MacOSX上运行Mathematica 8,尝试将最简单的程序编译为C.任何与C有关的东西都不能在Mathematica中运行.我安装了GCC 4.2; 我甚至用XCode多次重新安装它.这就是我正在做的和我得到的错误:
首先,我总是评估命令
Needs["CCompilerDriver`"]
Run Code Online (Sandbox Code Playgroud)
如果我将编译目标设置为C,
c = Compile[ {{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"];
Run Code Online (Sandbox Code Playgroud)
我得到一个错误,其中包含:Compile :: nogen:无法从已编译的函数创建库.
如果我尝试创建一个库,
demoFile = FileNameJoin[{$CCompilerDirectory,"SystemFiles","CSource","createDLL_demo.c"}];
lib = CreateLibrary[{demoFile},"testLibrary"]
Run Code Online (Sandbox Code Playgroud)
我收到消息$ Failed.Wolfram说这是因为我没有安装C编译器.我觉得很难相信因为我跑的时候
CCompilers[]
Run Code Online (Sandbox Code Playgroud)
它告诉我我已经安装了GCC:{{"Name" - >"GCC","Compiler" - > CCompilerDriver'GCCCompiler`GCCCompiler,"CompilerInstallation" - >"/ usr/bin","CompilerName" - >自动}}
更重要的是,终端说我也安装了GCC !! 任何帮助,将不胜感激.我真的很想将Mathematica编译成C.
c compiler-construction gcc wolfram-mathematica mathematica-8