Questions tagged [librarylink]
Wolfram LibraryLink provides a powerful way to connect external code to Mathematica, enabling high-speed and memory-efficient execution.
161
questions
3
votes
0
answers
88
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 ...
1
vote
0
answers
50
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 ...
3
votes
0
answers
56
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/...
20
votes
1
answer
872
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 ...
18
votes
1
answer
711
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 ...
2
votes
0
answers
46
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 ...
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
...
24
votes
2
answers
431
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 ...
14
votes
1
answer
645
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 ...
2
votes
1
answer
56
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 ...
2
votes
0
answers
45
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, ...
1
vote
1
answer
102
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 ...
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 ...
2
votes
0
answers
54
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 ...
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)....
26
votes
1
answer
645
views
LibraryLink: What can we do with MInputStream and MOutputStream?
Version 9 introduced the WolframStreamsLibrary.h header for LibraryLink. It contains MInputStream and ...
5
votes
1
answer
207
views
How to assign pointer to a rank 2 MTensor in Mathematica C code?
I've the following code
...
0
votes
0
answers
44
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 ...
4
votes
2
answers
211
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 ...
23
votes
2
answers
622
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:
...
8
votes
3
answers
254
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 ...
3
votes
1
answer
109
views
How to call the librarylink api in 13.1
Local file demo.c have some library link API example, such as:
example 1:
...
1
vote
0
answers
106
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 ...
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 ...
2
votes
0
answers
126
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 ...
6
votes
2
answers
470
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 ...
6
votes
1
answer
512
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 ...
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 ...
9
votes
2
answers
341
views
LibraryUnload fails
I can load my library, but I cannot unload it with LibraryUnload. I do have a ...
1
vote
0
answers
62
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....
3
votes
2
answers
124
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 ...
5
votes
1
answer
150
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 ...
3
votes
1
answer
266
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 ...
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....
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?
3
votes
0
answers
220
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 ...
5
votes
2
answers
236
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 ...
122
votes
7
answers
14k
views
Minimal effort method for integrating C++ functions into Mathematica
Update: While at the time of writing the question loading DLLs with .NET/Link seemed easier, now I always use LibraryLink, which I recommend to anyone with a similar problem!
As of Mathematica 8, ...
2
votes
1
answer
80
views
ParallelTable does not evaluate DLL functions
I have a function programed in C which I load in MMA with
...
1
vote
1
answer
167
views
LibraryFunctionLoad with Cool Prop documentation
I use the following command
...
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 ...
2
votes
2
answers
731
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 ...
12
votes
3
answers
1k
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, ...
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.
...
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 <...
16
votes
2
answers
671
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 ...
3
votes
1
answer
324
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 ...
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-...
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 ...
1
vote
1
answer
101
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 ...