creates a compiler environment that can be used in FunctionCompile and related functions.
CreateCompilerEnvironment
creates a compiler environment that can be used in FunctionCompile and related functions.
Details and Options
- CreateCompilerEnvironment returns a CompilerEnvironmentObject.
- Declarations can be added to a CompilerEnvironmentObject with CompilerEnvironmentAppendTo.
- The following option can be given:
-
TargetSystem Inherited machine architectures to be targeted - The possible values of TargetSystem are given in the list $TargetSystems.
Examples
open all close allBasic Examples (2)
Create a new compiler environment:
env = CreateCompilerEnvironment[]CompilerEnvironmentAppendTo[env, {FunctionDeclaration[AddTwo, Typed[{"Integer64"} -> "Integer64"]@Function[arg, 2 + arg]]}];Use the compiler environment in a compilation:
cf = FunctionCompile[Function[{Typed[arg, "Integer64"]}, AddTwo[arg]], CompilerEnvironment -> env]cf[2]Create an environment for a specific platform:
env = CreateCompilerEnvironment[TargetSystem -> "Windows-x86-64"]Target systems of the new environment:
env[TargetSystem]Options (1)
TargetSystem (1)
The default value of Inherited generates an environment for the current platform:
CreateCompilerEnvironment[]You can choose a target system for a specific platform:
CreateCompilerEnvironment[TargetSystem -> "Linux-x86-64"]You can choose several platforms:
env = CreateCompilerEnvironment[TargetSystem -> {"MacOSX-x86-64", "MacOSX-ARM64"}]You can see the target systems supported by an environment:
env[TargetSystem]The setting Automatic creates a number of core platforms:
env = CreateCompilerEnvironment[TargetSystem -> Automatic]You can use this in FunctionCompile:
comp = FunctionCompile[Function[{Typed[arg, "Integer64"]}, arg + 1], TargetSystem -> Automatic, CompilerEnvironment -> env]The CompiledCodeFunction object contains code for all of the platforms:
Information[comp, "LLVMBinary"]This is a useful way to carry out cross-compilations because the environments do not need to be created for each compilation.
Tech Notes
Related Guides
History
Text
Wolfram Research (2021), CreateCompilerEnvironment, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateCompilerEnvironment.html.
CMS
Wolfram Language. 2021. "CreateCompilerEnvironment." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CreateCompilerEnvironment.html.
APA
Wolfram Language. (2021). CreateCompilerEnvironment. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CreateCompilerEnvironment.html
BibTeX
@misc{reference.wolfram_2026_createcompilerenvironment, author="Wolfram Research", title="{CreateCompilerEnvironment}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/CreateCompilerEnvironment.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_createcompilerenvironment, organization={Wolfram Research}, title={CreateCompilerEnvironment}, year={2021}, url={https://reference.wolfram.com/language/ref/CreateCompilerEnvironment.html}, note=[Accessed: 13-June-2026]}