Skip to main content

Questions tagged [librarylink]

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

Filter by
Sorted by
Tagged with
4 votes
0 answers
93 views

Are ForeignFunction and its friends the next generation of LibraryLink?

It's a bit surprising to me that no one asks about this so far, so let me step up :) . In version 13.3, an EXPERIMENTAL Foreign Function Interface has been introduced. I'm by no means a C expert, but ...
xzczd's user avatar
  • 66.9k
1 vote
0 answers
52 views

Why I can't install this package [closed]

I am trying to run C++ in Mathematica. I got a package "LTemplate" from the answer from Szabolcs in this post: How to simplify writing LibraryLink code?. However I can't install it. This is ...
xpaul's user avatar
  • 261
3 votes
0 answers
59 views

GSL multiroot finding mode Hybrid function load with Mathematica : Crash

Hi everyone I work on a Mac M1 Sonoma 14.3 with Mathematica 12.3.1 and 14.0 I have an issue when using a C++ multiroot finding from GSL library. I used this example : https://www.gnu.org/software/gsl/...
Alex's user avatar
  • 51
2 votes
0 answers
49 views

How to load a .dylib library (C++ not compile with Mathematica library) on Mac with Mathematica?

I work on a mac M1 with MacOS Sonoma and i use Mathematica 12.3.1 and 14.0 I wanted to ask if there is a way to load a .dylib library on Mac with Mathematica, which was compiled without using the ...
Alex's user avatar
  • 51
2 votes
0 answers
37 views

Checking debug mode in C-code when call CreateLibrary with Debug -> True

I create a C-library and compile it using the tools in LibraryLink. When I create a code binary like this ...
Kirill Belov's user avatar
2 votes
1 answer
61 views

Exported function discovery with LibraryFunction

Many internal calls boil down to invocations like LibraryFunction["path/to/library", "funcName" , ...] I'm on a mac, so I can use the ...
Adam's user avatar
  • 3,956
2 votes
0 answers
46 views

How do I identify which external routine is potentially internally used when executing some built-in function?

Wolfram's website declares that "a large fraction of Mathematica's numerical algorithms are based on original research at Wolfram Research" (cf. So Many Original Wolfram Algorithms). So, ...
user688486's user avatar
1 vote
1 answer
110 views

LMDB Library cannot be loaded by `LibraryLoad`, how to compile properly

I cloned LMDB* from https://github.com/LMDB/lmdb and compiled on a Mac M1 with make -e clean liblmdb.so CC="cc -target aarch64-macos-none" which produced ...
Adam's user avatar
  • 3,956
18 votes
1 answer
714 views

Fast Hankel Function in Mathematica

I am working on a project that requires repeated calls to HankelH1[0, r] for $r$ spanning the full real axis. When I use the mathematica routine, it can be as much ...
JonBean's user avatar
  • 183
4 votes
1 answer
155 views

Third party libraries in LibraryLink

I am trying to use third-party libraries in LibraryLink, but the kernel crashes when I call their functions. In particular, I want to make available some functions of SuiteSparse to manipulate ...
Albercoc's user avatar
  • 998
2 votes
0 answers
55 views

Bug: managed library expressions are freed prematurely during evaluation

I believe I have run into a bug with managed library expressions and garbage collection behavior. In the example below, adapted from the documentation for ...
yousufferbutwhy's user avatar
3 votes
1 answer
104 views

Can I efficiently use a compiled function as an input to another compiled function?

I have a compiled function(such as $f\left(z,c\right)=z^2+c$) which will get replaced by different equations as the code runs. I'm using this compiled function(#1) inside another compiled function(#2)....
Laff70's user avatar
  • 171
5 votes
1 answer
210 views

How to assign pointer to a rank 2 MTensor in Mathematica C code?

I've the following code ...
csk 7's user avatar
  • 403
0 votes
0 answers
45 views

How can we change the EoS (to PR using the Flags function) for REFPROP used within Mathematica?

I would like to change the EoS used by REFPROP to the PR EoS for several calculations. It's stated that the Flags function must be used. " Peng-Robinson or PR 0: Turn off the Peng-Robinson ...
user265228's user avatar
3 votes
1 answer
110 views

How to call the librarylink api in 13.1

Local file demo.c have some library link API example, such as: example 1: ...
yode's user avatar
  • 26.8k
4 votes
2 answers
212 views

How to get a MTensor variable by a vector object

librarylink have a dirty signature such as: EXTERN_C DLLEXPORT int fun(WolframLibraryData libData,mint Argc, MArgument* Args, MArgument Res) But when we are in ...
yode's user avatar
  • 26.8k
23 votes
2 answers
627 views

How to call the C++ by the new LibraryFunctionDeclaration?

When we arrive at V13.1, we have a great LibraryFunctionDeclaration now, which can call C function in MMA as this article: ...
yode's user avatar
  • 26.8k
1 vote
0 answers
109 views

It is possible to call C functions with pointers as arguments in Mathematica?

Here is my goal: I want to call external library functions, written in C (not by me), in Mathematica. I may have found a way to do it using LibraryLink by following this scheme: First, for each ...
User3000's user avatar
  • 311
20 votes
1 answer
893 views

Is it possible to use the DGEEV and DSYEV LAPACK subroutines in Mathematica?

Here is my problem: I'm diagonalizing some matrices using Eigensystem[] to obtain eigenvalues and eigenvectors and I'm diagonalizing the same matrices using a ...
User3000's user avatar
  • 311
24 votes
2 answers
432 views

Which Mathematica versions have changed WolframLibraryVersion?

A LibraryLink library compiled with headers having a certain WolframLibraryVersion will not work with Mathematica versions that support only earlier ...
Szabolcs's user avatar
  • 235k
0 votes
0 answers
50 views

Is it possible to run kernel in address space of another process?

Kernel executables seem to be relatively small wrappers around "dynamic link library" that contains all the functionality of the kernel. Is it possible to load the kernel (as a dynamic link ...
Pavel Perikov's user avatar
2 votes
0 answers
128 views

LibraryFunctionLoad with swift library

I'm trying to figure out if there is any sane way to call a swift function using the LibraryLoadFunction. In Swift it seems possible to use @_cdecl to get a c callable dynamic library. When I test ...
Dave's user avatar
  • 81
6 votes
2 answers
476 views

Speedup the production of a sparse symmetric matrix with a dense vector

The optimization of the production of a sparse symmetric matrix with a dense vector has existed for a long time. Someone once compared the matrix operations of Mathematica with MATLAB, and then came ...
sidy's user avatar
  • 141
6 votes
1 answer
519 views

Mathematica call C++ Eigen to calculate sparsematrix multiplication

I want to use the C++ Eigen library in Mathematica's LibraryLink function. In the past, matheorem called C++ Eigen in Mathematica successfully. However, I am not ...
sidy's user avatar
  • 141
4 votes
0 answers
70 views

Should I worry about concurrent access to LibraryLinked code?

According to these answers, when several heterogeneous results (say {MTensor, mint, double}) are needed to be returned from a LibraryLink ...
iago-lito's user avatar
  • 163
8 votes
3 answers
261 views

Can LibraryLink receive and output a list of strings?

I need to use libraryLink to process a list of strings, I haven't found a suitable example, confused about the types of the arguments and return types. Does libraryLink directly support it, which one ...
expression's user avatar
  • 5,652
1 vote
0 answers
63 views

Substitute for MathLink to integrate PARI with Mathematica?

How does one access MathLink with current version of Mathematica? I'm trying to integrate the "computer algebra system" PARI with Mathematica, as documented at https://pari.math.u-bordeaux....
murray's user avatar
  • 11.9k
3 votes
2 answers
125 views

MTensor of MTensor (aka List of List)

In C++ I have a vector of 2D points : typedef std::array<double, 2> Point; std::vector<Point> samples; Now, I'm in LibraryLink and I'd want to pass a ...
Max Tarpini's user avatar
5 votes
1 answer
152 views

Difference between MTensor and MNumericArray in Mathematica

Since I'm starting to look into C-programming using LibraryLink to connect Mathematica to computational expensive calculations, I was wondering about the two available options within LibraryLink for ...
Rainer's user avatar
  • 2,931
2 votes
0 answers
126 views

LTemplate and external library Armadillo

As a great fan of the simplicity of the LTemplate library for the end user I am now faced with a problem when apparently everything compiles correctly but the functions are not loaded from the library....
pbx's user avatar
  • 842
6 votes
1 answer
87 views

Default compiler optimization flag used by LibraryLink (CreateLibrary)?

What's the default optimization level (e.g. -O2, -O3) used by the function CreateLibrary, which invokes the system compiler to compile C/C++ code for use in LibraryLink?
felix's user avatar
  • 549
3 votes
0 answers
222 views

Using MinGW-w64 from MSYS2 with LibraryLink

I am looking to use the MinGW-w64 version of gcc, as bundled with msys2, with LibraryLink. It was communicated to me that in recent versions of Mathematica, one may use the MinGWCompiler compiler ...
Szabolcs's user avatar
  • 235k
3 votes
1 answer
269 views

How to get information from all built-in Mathematica functions in order to create a Kotlin library like the Wolfram Client Library for Python?

I'd like to use (if this already exists) or create a library to use Mathematica together with Kotlin (or Java) (not JLink, please see below). We already have this very useful implementation for ...
GarouDan's user avatar
  • 1,536
5 votes
2 answers
247 views

Using WSTP with LibraryLink

I'm building an interface for a Fortran library. I would like to use LibraryLink and Mathematica to do the compilation (via CreateLibrary), Visual Studio is ...
Batox's user avatar
  • 153
2 votes
1 answer
81 views

ParallelTable does not evaluate DLL functions

I have a function programed in C which I load in MMA with ...
Denis Cousineau's user avatar
1 vote
1 answer
172 views

LibraryFunctionLoad with Cool Prop documentation

I use the following command ...
Cezary's user avatar
  • 11
0 votes
0 answers
36 views

Improving performance of LibraryLink evaluation

I have a large function that I want to integrate with an integration routine. The function is supposed to be built out of LibraryLink functions, but I find evaluating the function to be very slow, and ...
Marco's user avatar
  • 1
2 votes
2 answers
745 views

Couldn't load OpenSSL library in 12.1 (Windows)

Update: Finally I found a clumsy way to solve this bug by myself: I created an alternate local kernel to run the code, and it surprisingly works out! It is ridiculous that two local kernels contain ...
Pei-Xin Shen's user avatar
0 votes
0 answers
98 views

NestList with LibraryFunction

Edit Same behavior without FORTRAN and undocumented part. What can be wrong in this case? LibraryFunction below is supposed to be just an identity function. ...
I.M.'s user avatar
  • 2,996
5 votes
1 answer
115 views

MathLink: How do I send a bigint?

Suppose I have a big integer from some library such as GMP. I need to return this from a LibraryLink function. What is the most efficient way to do it? The simplest way is to convert it to a string <...
Szabolcs's user avatar
  • 235k
3 votes
1 answer
326 views

Meson build system + C/C++ LibraryLink, help needed for portability check/fix (Windows &MacOs)

As a proof of concept I have created a github repository that shows how to: use the Meson build system to create a Mathematica package using LibraryLink functions The goal is to provide an easy to ...
Picaud Vincent's user avatar
1 vote
0 answers
74 views

Loading machine learning library without enabling my discrete Nvidia GPU? [closed]

I've asked a similar question [here]. I cannot use some of the machine learning modules without enabling my discrete Nvidia GPU. My setup: Ubuntu 16.04 on a Dell XPS-15 9560 Intel i7 CPU with 8-...
nonreligious's user avatar
1 vote
0 answers
164 views

How to check the visibility of and load a dependency Dynamic Link Library (DLL) to the Kernel?

I compiled (on Windows 10, using MinGW) a Dynamic Link Library that implements an interface to another one. I then use LibraryLoad[dependencyDLL] and then ...
Pedro H. N. Vieira's user avatar
1 vote
1 answer
102 views

Problem with calling dll file using LibraryLink with ParallelMap and Map for large data

I am trying to call a .dll file via LibraryFunctionLoad where the .dll file is placed in "C:\ProgramData\Mathematica\SystemFiles\LibraryResources\Windows-\ x86-64\CoolProp.dll". When I call this ...
yaykhel's user avatar
  • 171
2 votes
2 answers
242 views

LibraryLink C++ void function, mathematica wrapper

I am trying to include a C++ function into the Mathematica wrapper. There is a void function to change the reference state. The original wrapper includes the following C++ function. Here is ...
yaykhel's user avatar
  • 171
2 votes
0 answers
108 views

LTemplate C++ code seems to run faster than the same code compiled outside of Mathematica

I am slightly puzzled by now and am not able to figure out what's going on inside of LibraryLink (used by LTemplate) to justify what I recognized: I have C++ code that is way too extensive to be ...
pbx's user avatar
  • 842
2 votes
1 answer
187 views

Compile errors after reloading of laptop contents after challenging MacOS Mojave installation

I tried (foolhardily, it appears) installing macOS Mojave Version10.4 on my MacBookAir, but encountered major problems--that seemed to have been (finally) fixed after a reinstallation and reloading of ...
Paul B. Slater's user avatar
3 votes
1 answer
72 views

Get Library Name from WolframLibraryData

When developing with LibraryLink, is there any way to get the function name from inside the library ? I don't think there is a way to find out the name of the function that have been used to access ...
Neel Basu's user avatar
  • 961
12 votes
0 answers
158 views

LibraryLink: How to read from a Mathematica stream in C?

Mathematica has a flexible streams interface. Functions like Read can read from a "stream" that may be backed by a file, pipe, string, network resource, etc. We can ...
Szabolcs's user avatar
  • 235k
5 votes
2 answers
94 views

Bounds for LibraryFunction arguments of integer type

I am trying to load a function written in C++ using LibaryFunctionLoad. Doing so, I have encountered an issue I believe to be a bug (I wanted to ask here first in ...
Lukas Lang's user avatar
  • 34.1k