Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how

Legacy Documentation

Mathematica 8 (2010)

This is documentation for Mathematica 8, which was
based on an earlier version of Wolfram Language.
View current documentation (Version 14.3)

CreateObjectFile


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

compiles a number of C source files and creates a library file, .
  • To use , you first need to load the CCompilerDriver package 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 object file depends on the platform on which it is created.
  • The following options can be given:
"Compiler" Automatic the compiler to use
"CleanIntermediate" Automatic whether temporary files should be deleted
"CreateBinary" True whether the object file should be created
"CompileOptions" "" options to pass through to the compiler
"CompilerInstallation" Automatic location of the compiler software
"CompilerName" Automatic which compile command to use
"Debug" False compiles with debug information, does not clean the intermediate output, and prints the compile commands and output
"Defines" {} C preprocessor defines to use for the build
"IncludeDirectories" {} directories to add to the include path
"Language" Automatic what language the source code is in (can be used to assume source is C or C++ rather than relying on automatic detection)
"PreCompileCommands" "" shell commands to run before compilation
"PostCompileCommands" "" shell commands to run after compilation
"ShellCommandFunction" None function to call with the shell commands used for compilation
"ShellOutputFunction" None function to call with the shell output of running the compilation commands
"SystemCompileOptions" {} options to pass through to the compiler before
"SystemIncludeDirectories" Automatic directories to locate Mathematica header files
"TargetDirectory" Automatic the directory in which the executable file should be created
"TargetSystemID" $SystemID the system for which output should be generated
"WorkingDirectory" Automatic the directory in which temporary files should be generated
(1)
Load the CCompilerDriver package:
Define a C function and compile it to an object file:
Include the object file with a main that uses it and compile it all into an executable:
Run the executable with and :
Compare the results to those computed by Mathematica:
Load the CCompilerDriver package:
Define a C function and compile it to an object file:
Out[2]=
Include the object file with a main that uses it and compile it all into an executable:
Out[3]=
Run the executable with and :
Out[4]=
Compare the results to those computed by Mathematica:
Out[5]=


ja zh

AltStyle によって変換されたページ (->オリジナル) /