List of LibraryLink examples

This is a list of a fully functional LibraryLink examples, starting with the bare minimum to more complicated cases:

  1. Doing nothing with LibraryLink -- Explains how to write a minimal example in LibraryLink that takes no arguments and returns nothing
  2. Saying hello with LibraryLink -- Explains how to return a value from a LibraryLink function
  3. Sending greetings from LibraryLink -- Explains how to pass in a value to a LibraryLink function
  4. Squaring integers with LibraryLink -- Explains how to write a basic arithmetic function with LibraryLink
  5. Writing a boolean function with LibraryLink -- Explains how to write a function that returns True or False
  6. Calculating the mean value of a list with LibraryLink -- Explains how to pass lists for a LibraryLink function
  7. Creating a matrix with LibraryLink -- Explains how to return a matrix from a LibraryLink function
  8. Working with complex numbers in LibraryLink
  9. Working with multiple functions in LibraryLink

LibraryLink examples which use WolframLink:

  1. Hello World revisited using WolframLink in LibraryLink
  2. Working with a variable number of arguments in LibraryLink
11 Likes

Hello Arnoud,

thanks for these very helpful examples. Unfortunately, there is a case missing:

I would like to pass several MTensors as a result via LibraryLink.

Say, I have a real matrix and a list of integers that I want to pass on.

Thanks,
Michael

Not sure how to do this off-hand, but I will ask some people who might know.

Another good place to look for a possible answer is the Q&A site called StackExchange:

A possible answer here:

https://mathematica.stackexchange.com/questions/31545/returning-multiple-results-from-a-librarylink-function

With a mirror post here:

Code is also available in this GitHub repository:

1 Like