Wolfram LibraryLink allows dynamic libraries to be directly loaded into the Mathematica kernel so that functions in the libraries can be immediately called from Mathematica. You can exchange not only C-like data types such as integers, reals, packed arrays, and strings, but also arbitrary Mathematica expressions. In addition, there are useful functions such as sending errors and calling back to Mathematica.

This section summarizes the functionality.

Mathematica Functions

This section summarizes the functions used to interact with Wolfram Libraries from Mathematica.

LibraryFunctionLoadload a function from a library
LibraryFunctionrepresentation of a handle to a function loaded from a library
LibraryFunctionUnloadunload a function that was previously loaded from a library
LibraryUnloadunload all functions previously loaded from a library

Mathematica functions for loading and unloading functions from Wolfram Libraries.

LibraryFunctionInformationreturns information about a LibraryFunction

Mathematica function for getting information about a function loaded from a Wolfram Library.

$LibraryPaththe path used to find libraries
FindLibraryfind a library on the library path

Mathematica functions for locating Wolfram Libraries.

LibraryLoadload a library without calling any functions

Mathematica function for loading a library to resolve dependencies.

$LibraryErrorsystem-dependent errors from loading libraries
LibraryVersionInformationrules containing information about the version of a library
LibraryVersionStringa string of library version information

Mathematica functions in the LibraryLink` package.

Library Callback Functions

This section summarizes C language callback functions used to implement libraries.

MTensor_newcreate a new MTensor
MTensor_freefree an MTensor
MTensor_disownallow a shared MTensor to be freed
MTensor_clonecopy an MTensor

Callback functions for creating and freeing an MTensor.

MTensor_getRankget the rank of an MTensor
MTensor_getDimensionsget the dimensions of an MTensor
MTensor_getFlattenedLengthget the number of elements of an MTensor
MTensor_getTypeget the type of an MTensor

Mathematica functions for getting structural information from an MTensor.

MTensor_getIntegerget an element from an MTensor of integers
MTensor_getRealget an element from an MTensor of reals
MTensor_getComplexget an element from an MTensor of complex numbers
MTensor_getMTensorget an MTensor sub-part from an MTensor
MTensor_getIntegerDataget the data of an integer MTensor
MTensor_getRealDataget the data of a real MTensor
MTensor_getComplexDataget the data of a complex MTensor

Mathematica functions for getting elements from an MTensor.

MTensor_setIntegerset an element in an MTensor of integers
MTensor_setRealset an element in an MTensor of reals
MTensor_setComplexset an element in an MTensor of complex numbers
MTensor_setMTensorset an MTensor subpart in an MTensor

Mathematica functions for setting elements in an MTensor.

Messagesend a message in Mathematica
AbortQcheck if an abort is in progress

Mathematica functions for handling errors in library functions.

UTF8String_disowncalled when a string argument is no longer used

Mathematica functions for working with strings.

getMathLinkset the error handling buffer
processMathLinksend a message in Mathematica

Mathematica functions for using MathLink in a library function.

New to Mathematica? Find your learning path »
Have a question? Ask support »