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....
user avatar
  • 111k
26 votes

What is the difference between MathLink and WSTP? Which one should I use?

There is no difference. "WSTP" is just a new name for MathLink. As part of the renaming they also changed the function names from ML-prefixed ones to ...
user avatar
  • 227k
25 votes
Accepted

How to use RunProcess to import external function?

Taking user5601's suggestion to do a little demo, I quickly whipped this up as an example of ProcessLink being used to do non-trivial communication between Mathematica and an external program, but ...
user avatar
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 ...
user avatar
  • 68.9k
16 votes
Accepted

WSTP broken by upgrade to 10.0.1?

Under Linux the WSTP shared libraries that ship with Mathematica 10.0.1 for both 64 and 32 bit (libWSTP64i4.so and libWSTP32i4.so...
user avatar
  • 4,888
16 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 ...
16 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 ...
user avatar
  • 1,136
16 votes

MathLink (WSTP) vs LibraryLink performance

At the end of this post you'll find the code for a small benchmark to compare LibraryLink with standard passing vs LibraryLink with MathLink based passing on two counts: function call overhead; use a ...
user avatar
  • 227k
16 votes

Can Mathematica edit large binary files in-place?

We can do it straightforward in Java using JLink: ...
user avatar
  • 6,278
14 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 ...
user avatar
  • 227k
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 ...
user avatar
  • 227k
12 votes
Accepted

Tools for MathLink traffic analysis?

The online documentation may indicate that the online documentation is obsolete; the LinkSnooper itself is still alive and kicking! Just go to the Documentation Center and look at the guide page of ...
user avatar
  • 111k
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 ...
user avatar
  • 12.4k
11 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 ...
user avatar
  • 12.4k
11 votes

Connect Frontend to Kernel Started by JVM via JLink

I was able to get a satisfactory answer to my question by using a very good article by David Wagner, "MathLink Mode" available here. I'll leave all the JVM stuff out of the answer but the approach ...
user avatar
  • 733
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 (...
user avatar
  • 227k
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 ...
user avatar
10 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 ...
user avatar
  • 111k
9 votes

How to use Mathematica functions in Python programs?

Better late than never, but the error in the python script appears to be due to the format of the current packet. Using your routine (with k = kernel): ...
user avatar
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 ...
user avatar
  • 227k
9 votes
Accepted

How to set up LinkSnooper for monitoring FrontEnd--Kernel communication?

Use the following command to create a new kernel setup with the name "LinkSnooper": ...
user avatar
  • 9,909
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 ...
user avatar
  • 227k
8 votes

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

In Version 10 we have BoundaryDiscretizeGraphics and RegionMember to the rescue. So here we go: Reproducing the graphics: <...
user avatar
  • 32.5k
8 votes
Accepted

Fast way to pass an array of integers to Java using JLink

The solution After a standard initialization step Needs["JLink`"] InstallJava[] What you have to do is actually very simple: ...
user avatar
8 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 ...
user avatar
  • 4,128
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. ...
user avatar
  • 941
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 ...
user avatar
  • 45.6k
7 votes

How to use Mathematica functions in Python programs?

Try Jupyter and SAGE notebook extensions for Mathematica: http://www.sagemath.org/doc/reference/interfaces/sage/interfaces/mathematica.html https://github.com/bjedwards/IPython-mathematicamagic-...
user avatar
7 votes

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

This is due to a bug in the example code. Specifically, in reverseString, the type of variable len should be ...
user avatar
  • 227k

Only top scored, non community-wiki answers of a minimum length are eligible