DeclareCompiledComponent
✖
DeclareCompiledComponent
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 "RawLibraryFunctions" functions to compile that are available as library exports "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.
- "RawLibraryFunctions" entries are given as a rule "name"Typed[funcName,ty]. This specifies that a compiled version of funcName with type ty will be exported by the library built for the component. If compilations use the component with CompiledComponentRawInterface, they can refer directly to funcName.
- "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 "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.
- The names of "RawLibraryFunctions" are limited by the format of dynamic libraries.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Create a compiled component "demo" containing a declaration:

https://wolfram.com/xid/0cpsqn29eiu0b2-2hv20e

https://wolfram.com/xid/0cpsqn29eiu0b2-ca2kh9

Use "demo" in a call to FunctionCompile:

https://wolfram.com/xid/0cpsqn29eiu0b2-8scmf7


https://wolfram.com/xid/0cpsqn29eiu0b2-2pl802


https://wolfram.com/xid/0cpsqn29eiu0b2-1t3xn9
Give a declaration for a compiled component:

https://wolfram.com/xid/0cpsqn29eiu0b2-8ki5g6
The compiled component object returns information about the component:

https://wolfram.com/xid/0cpsqn29eiu0b2-8x3ldp

The compiled component object has the following properties:

https://wolfram.com/xid/0cpsqn29eiu0b2-gbiirm

See the declarations added to a component:

https://wolfram.com/xid/0cpsqn29eiu0b2-9i8w7t

Scope (5)Survey of the scope of standard use cases
Declare a list of declarations in a component:

https://wolfram.com/xid/0cpsqn29eiu0b2-k3gext

https://wolfram.com/xid/0cpsqn29eiu0b2-mqj885
Declare an installed function:

https://wolfram.com/xid/0cpsqn29eiu0b2-jzuty8
Extract all properties of the component:

https://wolfram.com/xid/0cpsqn29eiu0b2-yvob35


https://wolfram.com/xid/0cpsqn29eiu0b2-mevctm

The declarations of a component:

https://wolfram.com/xid/0cpsqn29eiu0b2-nxx0ps


https://wolfram.com/xid/0cpsqn29eiu0b2-2gm560
DeclareCompiledComponent can give functions to compile into a library:

https://wolfram.com/xid/0cpsqn29eiu0b2-f4pmzx

https://wolfram.com/xid/0cpsqn29eiu0b2-sgtatn


https://wolfram.com/xid/0cpsqn29eiu0b2-vem10v

Call the code function from the library:

https://wolfram.com/xid/0cpsqn29eiu0b2-yzn798

DeclareCompiledComponent can define symbols to get installed code:

https://wolfram.com/xid/0cpsqn29eiu0b2-3yvd2t
Declare a function to exist in the component:

https://wolfram.com/xid/0cpsqn29eiu0b2-4eqtno
Add an installed function given only its name, looking up the definition in the compiler:

https://wolfram.com/xid/0cpsqn29eiu0b2-4fhen8

https://wolfram.com/xid/0cpsqn29eiu0b2-psclpz

Automatically load the component library by calling its installed functions:

https://wolfram.com/xid/0cpsqn29eiu0b2-mr8iqu


https://wolfram.com/xid/0cpsqn29eiu0b2-crud07

DeclareCompiledComponent can define symbols to get installed code:

https://wolfram.com/xid/0cpsqn29eiu0b2-6hmh6l
Declare a function to exist in the component:

https://wolfram.com/xid/0cpsqn29eiu0b2-84v2fj
Add an installed function given only its name, looking up the definition in the compiler:

https://wolfram.com/xid/0cpsqn29eiu0b2-s1w1qf

https://wolfram.com/xid/0cpsqn29eiu0b2-7ytgm5

Automatically load the component library by calling its installed functions:

https://wolfram.com/xid/0cpsqn29eiu0b2-pgr2k3


https://wolfram.com/xid/0cpsqn29eiu0b2-pxalr4

DeclareCompiledComponent can create a raw library interface to be used by other compiled code:

https://wolfram.com/xid/0cpsqn29eiu0b2-jg6847

https://wolfram.com/xid/0cpsqn29eiu0b2-wg74wg

Load and initialize the component library:

https://wolfram.com/xid/0cpsqn29eiu0b2-mlcfkb

A declaration of the function in the library:

https://wolfram.com/xid/0cpsqn29eiu0b2-wlwpt4
Compile a function that uses the library:

https://wolfram.com/xid/0cpsqn29eiu0b2-nxfwqv

Run the computation that calls the library:

https://wolfram.com/xid/0cpsqn29eiu0b2-01askk

Instead of using the LibraryFunctionDeclaration, the component raw interface can be used directly:

https://wolfram.com/xid/0cpsqn29eiu0b2-d6v8q


https://wolfram.com/xid/0cpsqn29eiu0b2-3ll0v8

This is useful because declarations from the component use the library without having to recompile them.
A component library built with "RawLibraryFunctions" can be used with ForeignFunctionLoad:

https://wolfram.com/xid/0cpsqn29eiu0b2-cu1tj9


https://wolfram.com/xid/0cpsqn29eiu0b2-y85ou

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.
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.
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
Wolfram Language. (2022). DeclareCompiledComponent. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html
BibTeX
@misc{reference.wolfram_2025_declarecompiledcomponent, author="Wolfram Research", title="{DeclareCompiledComponent}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html}", note=[Accessed: 08-July-2025
]}
BibLaTeX
@online{reference.wolfram_2025_declarecompiledcomponent, organization={Wolfram Research}, title={DeclareCompiledComponent}, year={2022}, url={https://reference.wolfram.com/language/ref/DeclareCompiledComponent.html}, note=[Accessed: 08-July-2025
]}