LibraryFunctionDeclaration

LibraryFunctionDeclaration["extName",lib,type]

represents a function declaration that exposes the library function extName with the type type from the library lib, for use in compiled code.

LibraryFunctionDeclaration[name->"extName",lib,type]

aliases the function with name in compiled code.

LibraryFunctionDeclaration[nameSpec,type]

assumes that the library will be loaded by the time the function is compiled.

Details

Examples

open allclose all

Basic Examples  (1)

Represent a declaration of a function from an external library:

Compile a program using the library function:

Scope  (2)

Give the function an explicit name:

Load a library manually with LibraryLoad:

Create a LibraryFunctionDeclaration that references a function already loaded into the kernel:

Using the compiled function after unloading the library can lead to crashes.

Applications  (1)

Represent a declaration of the SHA256 function from OpenSSL:

Compile a function that uses OpenSSL to compute the SHA256 hash of a string:

Compute the hash of a string:

Compare the computed hash with the built-in function Hash:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_libraryfunctiondeclaration, author="Wolfram Research", title="{LibraryFunctionDeclaration}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/LibraryFunctionDeclaration.html}", note=[Accessed: 06-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_libraryfunctiondeclaration, organization={Wolfram Research}, title={LibraryFunctionDeclaration}, year={2022}, url={https://reference.wolfram.com/language/ref/LibraryFunctionDeclaration.html}, note=[Accessed: 06-October-2024 ]}