DeclareCompiledComponent

DeclareCompiledComponent["name",decls]

adds declarations decls to compiled component "name".

DeclareCompiledComponent["name",fieldspec]

adds the specification spec to the specified field in the compiled component "name".

Details

  • Compiled components can be used to represent a named group of compiler declarations.
  • Compiled components can be used to represent compiled functionality that can be built into a shared library.
  • Compiled components can be embedded in paclets.
  • DeclareCompiledComponent["name",...] creates the compiled component "name" if it does not already exist.
  • Declarations from compiled components can be added to a compiler environment with CreateCompilerEnvironment and with CompilerEnvironmentAppendTo.
  • Declarations from compiled components are used when building installed and library functions.
  • A library that contains installed and library functions can be built with BuildCompiledComponent.
  • A library that contains installed and library functions can be loaded with LoadCompiledComponent.
  • The following values for field can be given:
  • "Declarations"declarations to use with the component
    "InstalledFunctions"functions to compile and symbols into which to install the results
    "LibraryFunctions"functions to compile, to be recovered by LoadCompiledComponent
    "LoadingEpilogs"functions to be executed after the component is loaded by LoadCompiledComponent
    "ExternalLibraries"libraries to be loaded before the component is loaded by LoadCompiledComponent
  • "Declarations" can be given as a single declaration or a list of declarations.
  • "InstalledFunctions" can be given as a rule symfunc that specifies that a compiled version of func will be installed in the symbol sym when the component built is loaded. "InstalledFunctions" can also accept an association of rules.
  • "InstalledFunctions" can be given a symbol sym, which will effectively declare the installed function symsym. If sym is the name of a compilable function (including one defined in the component), then it will be compiled and installed into the symbol sym for use outside compiled code. A list of symbols can also be given. »
  • "LibraryFunctions" can be given as a rule "name"func that specifies that a compiled version of func will be made available in the result of LoadCompiledComponent under the name "name". "LibraryFunctions" can also be given as an association.
  • "LoadingEpilogs" can be given as a single function or a list of functions.
  • "ExternalLibraries" can be given as a single library specification or a list of library specifications. Library specifications must be resolvable by FindLibrary.
  • The names of "LibraryFunctions" are limited by the format of dynamic libraries.
  • The "InstalledFunctions" and "LibraryFunctions" fields contain the source to be compiled. BuildCompiledComponent builds that source and saves the result to a dynamic library. The dynamic library can be loaded with LoadCompiledComponent to recover the results of the compilation.

Examples

open allclose all

Basic Examples  (2)

Create a compiled component "demo" containing a declaration:

View the resulting component:

Use "demo" in a call to FunctionCompile:

Clear the component:

Give a declaration for a compiled component:

The compiled component object returns information about the component:

The compiled component object has the following properties:

See the declarations added to a component:

Scope  (3)

Declare a list of declarations in a component:

Declare a library function:

Declare an installed function:

Extract all properties of the component:

Properties of a component:

The declarations of a component:

Clear the component:

DeclareCompiledComponent can give functions to compile into a library:

Build the library:

Load the library:

Call the code function from the library:

DeclareCompiledComponent can define symbols to get installed code:

Declare a function to exist in the component:

Add an installed function given only its name, looking up the definition in the compiler:

Build the component library:

Automatically load the component library by calling its installed functions:

Wolfram Research (2022), DeclareCompiledComponent, Wolfram Language function, https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html.

Text

Wolfram Research (2022), DeclareCompiledComponent, Wolfram Language function, https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html.

CMS

Wolfram Language. 2022. "DeclareCompiledComponent." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html.

APA

Wolfram Language. (2022). DeclareCompiledComponent. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html

BibTeX

@misc{reference.wolfram_2022_declarecompiledcomponent, author="Wolfram Research", title="{DeclareCompiledComponent}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html}", note=[Accessed: 04-February-2023 ]}

BibLaTeX

@online{reference.wolfram_2022_declarecompiledcomponent, organization={Wolfram Research}, title={DeclareCompiledComponent}, year={2022}, url={https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html}, note=[Accessed: 04-February-2023 ]}