Wolfram LibraryLink provides a powerful way to connect external code to Mathematica, enabling high-speed and memory-efficient execution.

learn more… | top users | synonyms

84
votes
6answers
7k views

Minimal effort method for integrating C++ functions into Mathematica

As of Mathematica 8, what is the minimal effort way to integrate an existing C++ function into Mathematica? I think we have these: MathLink (it was quite long ago I used it last time) communication ...
54
votes
1answer
590 views

How to simplify writing LibraryLink code?

LibraryLink is an API for extending Mathematica through C or C++. It is very fast because it gives direct access to Mathematica's packed array data structure, without even needing to make a copy of ...
25
votes
4answers
4k views

Efficiently determining if 3D points are within a surface composed of polygons

This is the 2nd part of a previous question which I edited to make into 2 separate questions: Extracting polygons from 3D contour plot surface As an extension of my earlier question involving simple ...
32
votes
1answer
2k views

Linking FORTRAN with Librarylink

FORTRAN code can be called using MathLink or .NET/Link (see the link for a worked examples). But as mentioned in a talk by T.Gayley and J.Klein in Wolfram Technology Conference 2011, LibraryLink, ...
12
votes
2answers
732 views

How can I use shared libraries in LibraryLink code and ensure Mathematica will find them?

I need to use shared libraries in some LibraryLink code. The shared library is installed in a custom location because it was also compiled by myself. When I try to load functions from the ...
6
votes
2answers
655 views

How to convert data types in a LibraryLink wrapper

I have a dynamic library which I want to load into Mathematica using LibraryLink. I don't have access to the source code of the library, so I need a C wrapper to do the job. In the C wrapper, I would ...
9
votes
1answer
288 views

How to use RunProcess to import external function?

I have a functions written in an external language called GO. How can I quickly load them into the kernel for use as Mathematica functions? The two ways I've tried are with MathLink and LibraryLink ...
19
votes
3answers
499 views

Returning multiple results from a LibraryLink function

What is the best way to return multiple inhomogeneous results from a LibraryLink function? Imagine that the result of a single computation is several tensors of different dimensions and several ...
11
votes
3answers
527 views

How to debug the C code for LibraryLink?

Recently, I use the C to rewrite a Mathematica function NonzeroBasis[], please see here for fully descriptions. Here, ...
7
votes
1answer
79 views

Is it possible for librarylink function to be Listable like that in Compile? [closed]

We know in Compile, there is an Option RuntimeAttributes -> {Listable} which can let the compiled function easily explore the ...
11
votes
1answer
286 views

Where is my memory? — LibraryLink never returns the memory

Bug introduced in 8.0 or earlier and persisting through 10.3 This is an example LibaryLink code from Mathematica documentation, which takes an integer and return an integer list: ...
16
votes
0answers
286 views

What are these new LibraryLink functions and datatypes for?

Looking at the LibraryLink examples, there are several new functions and objects, as well as example programs, that appeared in version 9. Are these documented? If yes, where? If would be nice to ...
15
votes
1answer
382 views

Using Boost with CreateLibrary

I was looking at the answer of Leonid of Faster alternatives for DayOfWeek and wanted to see how hard it would be to do something similar in C++ using an external library like Boost. I tried to ...
10
votes
1answer
419 views

How to use C language functions in Mathematica? [duplicate]

I'm trying to find out the way to use c-functions in Mathematica (I'm using 14 version) on OS X 10.10. For example I've got this lines of code: ...
15
votes
1answer
297 views

Dynamic and LibraryLink: dynamic visualization of a simulation

I am asking this question to save some time and I am expecting answers only from people who have tried something like this before. (I realize that I could just try it and see if it works, but that ...
12
votes
1answer
299 views

How to understand shared passing of a MTensor in LibraryLink?

According to the documentation, there are four different type of memory managing when passing a MTensor with LibraryLink: Automatic, "Constant", "Manual" and "Shared". The Automatic and "Manual" is ...
8
votes
1answer
298 views

Type conversion: LibraryLink mint vs. MathLink integer type

Assume the following situation: I have a WolframLibrary function which gets as parameter an integer tensor (which is for simplicity of rank 1) and the function should return an integer list through ...
14
votes
1answer
327 views

Asynchronous Programming

Consider that you would like to listen for Raw WiFi Packets coming into your NIC. Since Mathematica doesn't have built-in functions for such low level programming (as far as I know), one alternative ...
13
votes
1answer
90 views

How to service preemptive computations while running a LibraryLink function?

Cross-posted to Wolfram Community The following is from the comparison between WSTP (MathLink) and LibraryLink in the documentation: When the Wolfram Language is waiting for a WSTP application ...
10
votes
1answer
369 views

How to use MKL from Mathematica?

MKL has a lot of functions. The question is: how to use these functions directly from Mathematica? Furthermore, Mathematica shipped with some MKL libraries, which is located in ...
8
votes
1answer
177 views

How to use MacPorts' gcc with CreateLibrary?

Short version: What's the simplest way to use MacPorts' gcc with CreateLibrary? Long version: CreateLibrary uses ...
6
votes
1answer
148 views

How to return a string from LibraryLink?

I need to return a string from a LibraryLink function. The documentation states: When a string is returned as a result, the Wolfram Language accesses the memory to convert it to its own internal ...
9
votes
1answer
522 views

Converting other C++ classes to MTensor in LibraryLink

Hopefully this will be a quick question + a quick answer: Say I have a C++ (or C) code using LibraryLink. I am using a library that defines a specific matrix class, as many numerical libraries ...
10
votes
2answers
395 views

Why LibraryLink function crashes at a second time?

Bug introduced in 9.0 or earlier and fixed in 10.3 Update As Todd Gayley commented under halirutan's answer, this is a bug. I'm trying link one of Lapack's function to Mathematica through ...
4
votes
0answers
55 views

Is it possible to pass a “shared” integer in librarylink?

MTensor supports shared pass, where the argument can be modified in the library function and that modification can be seen in Mathematica side. Is it possible to do the same thing to a integer or ...
4
votes
0answers
105 views

2X slower with ; — LibraryLink performance problem [duplicate]

This is the continued problem of the LibraryLink memory usage question here and here. In the following code, there is a 2X performance difference with only the change of ";". ...
2
votes
1answer
5k views

Visual Studio Express 2010 on x86-64: libcmt.lib missing

The CCompilerDriver documentation explains that to use visual studio express on 64-bit targets, it's necessary to install the windows SDK after installing visual studio. I have done this, first ...
1
vote
0answers
33 views

Is it possible to pass a rank-0 tensor to LibraryLink?

There is such a thing as a rank-0 MTensor. It's mentioned here. Can we pass such an object to a LibraryFunction? How? This question is mostly out of curiosity, and not practical need. But it might ...