此为 Mathematica 8 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

CreateExecutable


compiles a string of C code and creates an executable file, .

compiles a number of C and mprep source files and creates an executable file, .
  • To use , you first need to load it using Needs.
  • If source is a string, treats it as C code. If source is a list of one or more strings, it treats it as a list of files that contain C code.
  • If cannot find a suitable C compiler, it issues a message and returns $Failed.
  • The extension given to the library depends on the platform for which the executable is created.
  • If an input file has the extension .tm, will treat it as a MathLink template file and use mprep to process it.
  • The following options can be given:
"Compiler"Automaticthe compiler to use
"CleanIntermediate"Automaticwhether temporary files should be deleted
"CreateBinary"Truewhether the library file should be created
"CompileOptions"""options to pass through to the compiler
"CompilerInstallation"Automaticlocation of the compiler software
"CompilerName"Automaticwhich compile command to use
"Debug"Falsecompile with debug information, do not clean the intermediate output, and print the compile commands and output
"Defines"{}C preprocessor defines to use for the build
"ExtraObjectFiles"{}previously compiled object files to include in the executable
"IncludeDirectories"{}directories to add to the include path
"Language"Automaticwhat language the source code is in (can be used to assume source is C or C++ rather than relying on automatic detection)
"Libraries"{}libraries to use to build the executable
"LibraryDirectories"{}directories to add to the library lookup path
"LinkerOptions"{}options passed to the linker
"PreCompileCommands"""shell commands to run before compilation
"PostCompileCommands"""shell commands to run after compilation
"ShellCommandFunction"Nonefunction to call with the shell commands used for compilation
"ShellOutputFunction"Nonefunction to call with the shell output of running the compilation commands
"SystemCompileOptions"{}options to pass through to the compiler before
"SystemIncludeDirectories"Automaticdirectories to locate Mathematica header files
"SystemLibraries"AutomaticMathematica libraries such as MathLink
"SystemLibraryDirectories"Automaticdirectories to locate Mathematica libraries
"SystemLinkerOptions"{}options passed to the linker before
"TargetDirectory"Automaticthe directory in which the executable file should be created
"TargetSystemID"$SystemIDthe system for which output should be generated
"WorkingDirectory"Automaticthe directory in which temporary files should be generated
  • If the result is to be quite independent of Mathematica, then the option should be set to : this makes sure that MathLink libraries are not included in the link stage.
First, load the package:
This creates an executable:
This runs the executable:
First, load the package:
In[1]:=
Click for copyable input
This creates an executable:
In[2]:=
Click for copyable input
Out[2]=
This runs the executable:
In[3]:=
Click for copyable input
Out[3]=