CompiledComponent
CompiledComponent[name]
表示一个已编译组件.
更多信息
- 已编译组件可用于表示一组已命名的编译器声明.
- 已编译组件可用于表示可内置到共享库中的编译功能.
- 可将已编译组件嵌入到小数据包中.
- 由 DeclareCompiledComponent 创建已编译组件.
- CompiledComponent 对象可用于添加编译声明.
- CompiledComponent 对象可用于发现已编译组件的详细信息.
- 可用 DeleteObject 清除 CompiledComponent 对象. »
- 可用 CompiledComponent[name][field] 访问已编译组件的字段.
- CompiledComponent[name][All] 返回组件中所有字段的关联.
- 已编译组件包含以下字段,可用 DeclareCompiledComponent 对其进行修改:
-
"Declarations" 与组件一起使用的声明 "InstalledFunctions" 要编译的函数和要将结果嵌入的符号 "LibraryFunctions" 要编译的函数,由 LoadCompiledComponent 恢复 "RawLibraryFunctions" 编译可作为库导出的函数 "LoadingEpilogs" LoadCompiledComponent 加载组件后要运行的函数 "ExternalLibraries" LoadCompiledComponent 加载组件之前要加载的库 - "InstalledFunctions" 和 "LibraryFunctions" 字段包含要编译的源代码. BuildCompiledComponent 对源进行构建并将结果保存到动态库中. 可用 LoadCompiledComponent 加载动态库,以恢复编译结果.
范例
打开所有单元 关闭所有单元基本范例 (2)
DeclareCompiledComponent["demo", FunctionDeclaration[square, Typed[{"Real64"} -> "Real64"]@Function[x, x ^ 2]]];CompiledComponent["demo"]在对 FunctionCompile 的调用中使用 CompiledComponent:
comp = FunctionCompile[CompiledComponent["demo"], Function[Typed[arg, "Real64"], square[arg]]]comp[10]DeleteObject[CompiledComponent["demo"]]DeclareCompiledComponent["demo2", FunctionDeclaration[multiply12, Typed[{"Real64"} -> "Real64"]@Function[x, x * 12]]];用 CompiledComponent 将声明添加到编译器环境中:
CompilerEnvironmentAppendTo[CompiledComponent["demo2"]];comp = FunctionCompile[Function[Typed[arg, "Real64"], multiply12[arg]]]comp[10]范围 (1)
DeclareCompiledComponent["fullComponent", {
FunctionDeclaration[return12, Typed[{} -> "MachineInteger"]@Function[{}, 12]],
FunctionDeclaration[addtwo, Typed[{"MachineInteger"} -> "MachineInteger"]@Function[x, x + 2]]
}];DeclareCompiledComponent["fullComponent", "LibraryFunctions" -> <|
"libFunc" -> Function[Typed[arg, "Real64"], Sqrt[arg]]
|>];DeclareCompiledComponent["fullComponent", "InstalledFunctions" -> addtwo];CompiledComponent["fullComponent"][All]CompiledComponent["fullComponent"]["Properties"]CompiledComponent["fullComponent"]["Declarations"]DeleteObject[CompiledComponent["fullComponent"]]技术笔记
-
▪
- Wolfram 编译器手册 ▪
- 编译组件
相关指南
-
▪
- 代码编译
文本
Wolfram Research (2022),CompiledComponent,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CompiledComponent.html.
CMS
Wolfram 语言. 2022. "CompiledComponent." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/CompiledComponent.html.
APA
Wolfram 语言. (2022). CompiledComponent. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CompiledComponent.html 年
BibTeX
@misc{reference.wolfram_2026_compiledcomponent, author="Wolfram Research", title="{CompiledComponent}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/CompiledComponent.html}", note=[Accessed: 10-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_compiledcomponent, organization={Wolfram Research}, title={CompiledComponent}, year={2022}, url={https://reference.wolfram.com/language/ref/CompiledComponent.html}, note=[Accessed: 10-September-2026]}