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

learn more… | top users | synonyms

4
votes
0answers
28 views

Is it possible to call a generic dll/so shared library from Mathematica

In Python, there's something called ctypes. With ctypes, one can call any shared library function and get the results back to your script. It supports all kinds of C-language types, such as int, ...
8
votes
1answer
140 views

Why does this LibraryLink function crash?

Recently, I have rewritten pure Wolfram Language implementation CAGDBSplineSurface[] with C. Below is main LibraryLink code: LibraryLink Code ...
3
votes
1answer
93 views

How to call other C function in LibraryLink? [closed]

In LibrayLink, a C function more or less will call other auxiliary C functions. Below is a instance: In this example, two auxiliary functions FindSpan() and <...
10
votes
2answers
109 views

Is it possible to attach a debugger to a dynamically linked library on the supported OS?

Recently, I discovered that LibraryLink technique is a very useful tool to improve the performance of function. Firstly, I need to use LibraryLink template to write C/C++ program. Then compiling the ...
11
votes
3answers
569 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, ...
13
votes
1answer
285 views

How to learn the LibraryLink technique for the newcomer?

Description For the built-in programming language(or called Wolfram Language) of Wolfram Mathematica, I think it is much easier and simpler to learn than other computer language(such as C/C++ or java)...
5
votes
1answer
77 views

getWSLINK documentation vs reality

The example in the documentation for getWSLINK says WSLINK link = libData->getWSLINK(libData); Compiling ...
0
votes
0answers
26 views

How to get a script to print MaxMemoryUsed[] upon getting a system signal?

I want to instrument a Mathematica script so that, upon receiving any system signal (e.g. SIGINT, aka Ctrl-C) it will print1 the ...
1
vote
0answers
47 views

Need some help on using LibraryLink

I'm learning to set up a LibraryLink in Mathematica. I'm able to reproduce some basic examples provided in Wolfram community. But I got stuck while doing a new one by myself. My source C file is ...
1
vote
0answers
59 views

How to call python code on an image

I have lots of image processing code written in python and would like to call it from within mathematica. Is there a way to transmit the image data directly like with c++ and LibraryLink? I'd rather ...
3
votes
0answers
45 views

weird behaviour of Listable fortran Librarylink function: different result each evaluation

I am working with fotran librarylink function currently. In this post, I will show some weird result of Listable fortran librarylink generated by intel compiler under windows (I tried gcc on linux the ...
3
votes
0answers
63 views

Why is a LibraryLink function, which returns a list, not parallelizing with ParallelTable?

First example: librarylink function return a list of two element ...
7
votes
1answer
80 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 ...
3
votes
0answers
83 views

LibraryLink: Asynchronous Examples

Inside the directory structure of LibraryLink there are several example files. Basically, they are divided in two types: Synchronous: demo.c, demo_error.c, ...
3
votes
2answers
215 views

What is the best way to work with complex number array in librarylink function in terms of C++ and Eigen?

I want to use C++ Eigen library in Mathematica Librarylink function. Currently, I have no problem dealing with real arrays. But I don't know what is the best way to deal with complex array in ...
14
votes
1answer
333 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 ...
3
votes
1answer
189 views

CreateLibrary for CUDA with NVCCCompiler

I am currently learning to use CUDA to speed up calculations. The book I am working with uses C code on the CPU to supply certain variables etc.. So I would like to compile the give code in ...
1
vote
0answers
95 views

How to load to Mathematica functions linking to MKL with LibraryLink on OSX

I'm trying to load library funcitons to Mathematica which are using MKL functions but I'm constatly getting LibraryFunction::libload on OSX (this works fine on ...
1
vote
0answers
78 views

Getting error LibraryFunction::version from calls to LibraryFunctionLoad

I am having trouble running my program and keep getting this error: LibraryFunction::version: The version number 2 of the library is not consistent with the current or any previous ...
8
votes
0answers
109 views

How to prevent the kernel from exiting when a LibraryLink function segfaults?

I do realize that this might be controversial, but I believe I have a real need for it this time. If a process tries to access memory at a location it doesn't own, it will by default exit with a "...
1
vote
0answers
34 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 ...
54
votes
1answer
624 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 ...
9
votes
2answers
133 views

Why does this LibraryLink example of LinkObject based passing not work? Bug or user error?

There's an example of LinkObject-based passing in the LibraryLink documentation. Unfortunately the cell in the documentation notebook is corrupted, but to skip ...
13
votes
1answer
91 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 ...
15
votes
1answer
206 views

MathLink (WSTP) vs LibraryLink performance

Has anyone benchmarked LibraryLink vs MathLink when passing large arrays? Specifically I would like to know how performance compares when using the following to pass and return a large array: ...
2
votes
1answer
60 views

Where does the LibraryLink version information come from?

LibraryVersionInformation returns the following information: ...
1
vote
1answer
60 views

List all managed library expressions

Is it possible to get a list of all existing managed library expressions, from within Mathematica? Mathematica clearly needs to keep track of which ones exist. Or do I need to refer to the table of ...
6
votes
1answer
122 views

Call library function in compile

On the Wolfram official website, there is an example of calling library function in a compiled function: ...
12
votes
2answers
163 views

How to properly generate messages from LibraryLink function?

I'm currently using WolframLibraryData::Message to generate messages from a library function, like this: ...
1
vote
1answer
245 views

Calling C++ from Mathematica Mac OS X

I am trying to call and run the C++ code at the bottom of this post which must be stored in a file called poissonvariate.cpp. I am getting the following error message which I will display here before ...
1
vote
3answers
125 views

Is there a global setting for number form

I'm creating strings which represent equations in C to use with library link. The problem I have is that numbers in ScientificForm are no longer useful after they ...
1
vote
1answer
35 views

Overwrite libraries created by LibraryLink

I'm using Library link on external C files which creates libraries for mathematica to use, but when i modify the source files and try to rebuild the libraries, the new libraries don't overwrite the ...
3
votes
0answers
176 views

Extracting an equation from an interpolated function

Im trying to use LibraryLink to do some calculations in C but part of the expression i want to calculate is an Interpolating Function. C cant use that obviously so I'm trying to shift it to a data ...
5
votes
1answer
402 views

How can I integrate Open-CV with Mathematica?

I would like to run Open-CV functions from within Mathematica, can anyone figure out how to do this?
2
votes
1answer
325 views

i cannot create a standalone executable from an exported Mathematica function

I generated the C code: compute.c ...
9
votes
1answer
297 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 ...
10
votes
1answer
439 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: ...
1
vote
0answers
38 views

LibraryFunctionLoad not recognizing datatype

I am trying to use LibraryFunctionLoad with a function that relies on a derived type that is defined within the library. I've loaded the library prior to calling <...
3
votes
1answer
117 views

LibraryLink path problem

I have a library function that need to load some external data files. But it looks that the path in the default path of library function is the path that Mathematica is currently in. Is there a way ...
10
votes
1answer
375 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 ...
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 ...
6
votes
1answer
150 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 ...
7
votes
1answer
105 views

LibraryLink: is WolframLibraryData libData persistent?

I am writing some C++ code that I want to call both through LibraryLink and independently from Mathematica. Thus it must be compatible with LibraryLink but not depend on it. When calling it from ...
5
votes
1answer
135 views

Undocumented WolframLibraryData::evaluateExpression

It seem there's this promising function in the callback object provided to MathLink C functions: ...
6
votes
1answer
115 views

Machine precision infinity

Is it possible to obtain the machine precision (double) version of Infinity? This is useful when using LibraryLink and C ...
4
votes
0answers
145 views

Compiling/calling Mathematica-generated .so from C

I'm trying to call a compiled function from a C program. I am generating the static object ...
4
votes
0answers
120 views

LibraryLink parallel performance

I'm trying to use a LibraryLink function in parallel. It is an embarrassingly parallel problem, so that no dependency between those parallel tasks. However I can only get the parallel efficiency about ...
2
votes
0answers
67 views

How does parallelization of LibraryLink function call work?

I'm trying to call a C function in parallel through LibraryLink. Here is an example kind of demonstrates that library function can be used in parallel. My question is what happened in the library ...
12
votes
1answer
307 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 ...
13
votes
1answer
216 views

What are the differences between library call back functions and WolframCompileLibrary macros?

I'm trying to use LibraryLink in Mathematica, and come across some problems. Consider if we have a MTensor m1 which contains a one dimensional double array, and I ...