35
votes
Accepted
Asynchronous Programming
Let me give you a very basic example, how you can employ an asynchronously running LibraryLink function for this specific task. I will not do any real packet listen, but only explain the general setup....
23
votes
Accepted
Fast Hankel Function in Mathematica
This is LibraryLink code with compiler and linker options specifically for macos on Apple Silicon.
These are the prerequisites to compile and run this successfully:
XCode installed along with the ...
22
votes
Multiplayer game in Mathematica: how to communicate between kernels?
Thanks to the new Channel functionality in Mathematica 11, it is now easy to make (basic) multiplayer games with Mathematica!
To demonstrate, I'll modify my hex ...
19
votes
What is the complete list of valid FrontEnd Packet types?
I thought I'd keep a running tally of what I know about these packets (excluding the obvious ones like CreatePalettePacket) just for reference.
Text / Box ...
17
votes
Minimal effort method for integrating C++ functions into Mathematica
In terms of loading C++ functions, I would strongly suggest LibraryLink. It is a great tool except that it requires you to write sometimes intimidating C code.
To make LibraryLink easier to use, I ...
16
votes
Can Mathematica edit large binary files in-place?
We can do it straightforward in Java using JLink:
...
15
votes
Minimal effort method for integrating C++ functions into Mathematica
There is a package called LTemplate that automates writing some of the boilerplate code for LibraryLink:
How to simplify writing LibraryLink code?
I consider this less effort than writing standard ...
14
votes
Accepted
C++ interface to large project
This cannot be answered very well without knowing your C++ library much better.
As you said, you have a choice between MathLink and LibraryLink. Generally, I recommend LibraryLink because:
It runs ...
12
votes
Accepted
Why does LinkRead block when LinkReadyQ returns True?
Sorry, it turns out there's a fairly critical omission in the documentation. LinkReadyQ, and its C cousins WSReady and ...
11
votes
Can you trigger update of Dynamic elements from a LinkedLibrary?
Preface
I will give a complete solution that shows how a dynamic file watcher can be implemented in Mathematica. The file watcher will track the size of the file and when it changes automatically ...
11
votes
Callable interface
You should not test pairs of graphs for isomorphism, as that is quadratic in the number of graphs, and it's hopeless. You should compute a canonical labelling of each graph with a suitable library (...
10
votes
How to return escaped characters from MathLink?
halirutan's answer is correct, but more could be said on the matter, so I'll expand.
First, MathLink/WSTP has no knowledge about the long-name form of various characters. The only Wolfram Language ...
10
votes
Accepted
What is the correct path to add a camera driver?
After 2 years of research and posting this question in other sites, the answer is that although Mathematica (Windows) detects the Camera device, only imaging devices using the Windows video image ...
9
votes
Write C/C++ programs calling Mathematica functions
The other answers ignore that you are asking about C or C++ (not C# or Java!)
Mathematica can be called from C (or C++) through the MathLink interface (recently renamed to WSTP). To learn it, I ...
9
votes
Accepted
WSTP simplifying expression from C
You are not evaluating
FullSimplify[(a + a + a + a - b)]
You are evaluating
FullSimplify["(a + a + a + a - b)"]
You used ...
9
votes
Link server WSTP API feature not receiving incoming connections
You are missing just one bit of secret sauce to get this to work. When you connect to a LinkServer link directly using WSTP/MathLink functionality, you need to use "-linkoptions 4" in the arguments to ...
7
votes
Write C/C++ programs calling Mathematica functions
C Style
To Call Mathematica functions from C/C++ you need to use ML_ or WS_ functions. ...
7
votes
How to use Mathematica functions in Python programs?
As yet another solution, you can use a new package called PJLink which implements JLink for python.
Once you have the package installed you start a KernelLink ...
7
votes
Accepted
Creating a persistent WSTP application
There are a number of misunderstandings in your question.
The C++ application then terminates, though the WSTP link can be left installed, which speeds things up if wstpfunction[] is called again. ...
7
votes
Can Mathematica edit large binary files in-place?
I have noticed that NETLink does not get a lot of love on this site (at least not as much as JLink does), so let me just post ...
7
votes
Control a Mathematica kernel from the front-end and from python
For this I'll make use of a little thing I recently wrote to answer a much deeper question: Control Front End in "mathlink" mode
The heart of this will be a little package to make a kernel ...
7
votes
How to send packed array from math kernel to 3rd party app via WSTP
Following a dedicated discussion with @Szabolcs, very helpful comments from @ihojnicki, and information from an old thread, I successfully implemented NumPy array sender/receiver in PyWSTP.
Assume we ...
6
votes
WSTP hangs up in Mathematica 10.2
The hang (or wait for a WSTP connection) is due to the WSTP executable not starting. As the "error while loading shared libraries" message indicates, this is because it cannot find its ...
6
votes
Accepted
How return an object of a struct from c to Mathematica?
In file.tm, you need to set the return type to Manual, and declare your C(++) function to be void.
Then return each piece of ...
6
votes
Accepted
MathLink: How to change the default listening IP address?
Use the undocumented LinkHost option, e.g.:
LinkCreate[LinkProtocol -> "TCPIP", LinkHost -> "127.0.0.1"]
yields:
...
6
votes
Accepted
MathLink: What is the difference between MLPutNext and MLPutType?
XXPutNext is XXPutType. I'm pretty certain XXPutNext exists only for backwards ...
5
votes
Returning multiple results from a LibraryLink function
Motivation
I was inspired by the discussion in this thread to investigate using JSON to return multiple data types in a single LibraryLink call. I'm posting this ...
5
votes
Correct way to handle mysterious NaN` result from MathLink function
This perhaps more of a comment than an answer, but I'm putting it in answer form so it will have more visibility.
The IEEE NaN number is not supposed to existing in the WL. That value is represented ...
5
votes
Control Front End in "mathlink" mode
With Custom REPL & Access to Kernel From Outside Process
Non-Blocking Version Update
There were issues with the front-end somehow (I really have no idea how) accessing the kernel outside of the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mathlink-or-wstp × 258interoperability × 27
librarylink × 22
c++ × 22
java × 17
.netlink × 16
programming × 15
remote-access × 14
parallelization × 12
kernel × 11
front-end × 9
external-calls × 9
windows × 8
functions × 6
performance-tuning × 6
python × 6
linux × 6
bugs × 5
mac-os-x × 5
kernel-startup × 5
notebooks × 4
packages × 4
scripting × 4
networking × 4
graphics × 3