Questions tagged [mathlink-or-wstp]

MathLink is a suite of Mathematica functions that implement a protocol for the communication/interfacing of Mathematica with external programs.

Filter by
Sorted by
Tagged with
47 votes
1 answer
2k views

Transferring a large amount of data in parallel calculations

Bug fixed in version 11.1 Functions like MemberQ, FreeQ, etc. no longer unpack. Yay! This question is inspired by one of @...
user avatar
  • 227k
121 votes
7 answers
13k 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, ...
user avatar
  • 227k
31 votes
2 answers
2k views

What is the complete list of valid FrontEnd Packet types?

In response to my question How can I get the unchanged Box form of an arbitrary expression? John Fultz answered with a method using the hilariously named ...
user avatar
  • 265k
70 votes
6 answers
30k views

How to use Mathematica functions in Python programs?

I'd like to know how can I call Mathematica functions from Python. I appreciate a example, for example, using the Mathematica function Prime. I had search about MathLink but how to use it in Python ...
user avatar
  • 1,436
13 votes
1 answer
835 views

Passing back "NaN`" and "Inf`" to C via MathLink

In the "usual" double representation of floating point numbers in C there is a NaN and an Inf...
user avatar
  • 227k
12 votes
1 answer
749 views

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

What is the simplest way to set up LinkSnooper to monitor the communication between the Kernel and the Front End? I am looking for an answer that works on all platforms, including 32-bit Windows.
user avatar
  • 9,909
22 votes
2 answers
612 views

MathKernel doesn't return all Messages

In Mathematica I run this command: Plot[Sin[x], {x, 1, 15}, GridLines -> error] It generates a Plot with this error message: A GridLines specification ...
user avatar
  • 1,412
25 votes
6 answers
1k views

Returning multiple results from a LibraryLink function

What is the best way to return multiple inhomogeneous results from a LibraryLink function? Imagine that the result of a single computation is several tensors of different dimensions and several ...
user avatar
  • 227k
28 votes
4 answers
8k views

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

This is the 2nd part of a previous question which I edited to make into 2 separate questions: Extracting polygons from 3D contour plot surface As an extension of my earlier question involving simple ...
user avatar
  • 9,482
18 votes
1 answer
562 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: ...
user avatar
  • 227k
33 votes
3 answers
2k views

Calling IronPython code from Mathematica

I'd like to call some IronPython code from Mathematica using .NET/Link. The problem is that the code lives in .py files, yet from Mathematica I can only load .NET assemblies which are DLLs. So it ...
user avatar
  • 1,597
14 votes
1 answer
1k views

How to run mathlink external commands in parallel?

I have an external function called increment (for the sake of illustration) that I call from Mathematica using MathLink. I.e., ...
user avatar
  • 4,941
11 votes
1 answer
2k views

Example program for calling Mathematica from C

I want to call Mathematica from a C program. Suppose I have two numbers x = 2 and y = 3. I want to define ...
user avatar
  • 111
11 votes
1 answer
2k views

Using Mathlink with the cernlib FORTRAN package MINUIT

I could successfully use Mathlink to call a simple fortran subroutine. However, when I went to a realistic problem, I failed. To be specific, I want to fit a set of data with some function using the ...
user avatar
  • 1,477
8 votes
1 answer
202 views

How to send packed array from math kernel to 3rd party app via WSTP

Background I'm developing a small python wrapper PyWSTP. The wrapper is still in very early stage and lacking features. One important feature I'm considering is transferring dense array between math ...
user avatar
  • 633
19 votes
1 answer
1k views

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

What is the difference between MathLink and WSTP programs? Will the use of MathLink protocol be maintained or not?
user avatar
  • 191
23 votes
2 answers
878 views

Multiplayer game in Mathematica: how to communicate between kernels?

This may have been asked already, but I am considering making a game in Mathematica that two people can play. However, the issue with my idea is that the other player can't view the cards of the first ...
user avatar
29 votes
1 answer
1k 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 ...
user avatar
13 votes
1 answer
599 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 ...
user avatar
  • 3,523
17 votes
5 answers
2k views

Connecting to and disconnecting from a continuously running kernel, on demand

I realized that there are lots of advantages to driving C/C++/FORTRAN code directly from Mathematica as LibraryLink functions (instead of running them from the command line or a shell script, as I ...
user avatar
  • 227k
7 votes
1 answer
216 views

Can you trigger update of Dynamic elements from a LinkedLibrary?

Is it possible to write a LinkedLibrary (or WSTP executable) computing a function f such that Dynamic@f[] is updated when the ...
user avatar
  • 5,619
11 votes
1 answer
640 views

WSTP broken by upgrade to 10.0.1?

Bug introduced v10.0.1 and fixed in 10.0.2 Everything was working fine with WSTP (the successor to MathLink) in 10.0.0. But I upgraded to 10.0.1 today and now I can't compile either my programs (I've ...
user avatar
  • 8,628
3 votes
1 answer
419 views

How could get all escape characters in Mathematica?

I am evaluating expression by using KernelLink. But the kernel will be suspended endless when meets a invalid escape character. ...
user avatar
  • 491
13 votes
2 answers
807 views

Connect Frontend to Kernel Started by JVM via JLink

I have a MathKernel started and controlled via JLink from a JVM. The $CommandLine for this kernel is: ...
user avatar
  • 733
14 votes
2 answers
540 views

Link server WSTP API feature not receiving incoming connections

I'd like to apologize ahead of time that this may be a very long post but want to get all of this out there. Also, this post really only pertains to those with WSTP/MathLink experience. My problem ...
user avatar
  • 582
11 votes
1 answer
933 views

Running .NET/Link on Mono (On MacOS or any UNIX or Linux Distro)

Has anyone have any luck running .NET/Link on Mono? When I run .NET/Link to call Mathematica from within a Mono program, this is the error message I receive. ...
user avatar
  • 213
9 votes
2 answers
572 views

Is it possible to set a timeout for LinkWrite[]?

This came up in relation to this answer Is it possible to set a timeout for LinkWrite? LinkWrite seems to block until the sent ...
user avatar
  • 227k
15 votes
4 answers
2k views

Correct way to handle mysterious NaN` result from MathLink function

I have a Mathematica expression that is mapped onto an external C function via MathLink. The external function passes a ...
user avatar
  • 4,941
5 votes
2 answers
536 views

A bug fix to mathematica 10.0.1.0

There is a bug in the Wolfram Symbolic Transfer Protocol Development in C (Windows). I described it in the next answer by myself, from which I summarize: One cannot successfully compile the ...
user avatar
5 votes
1 answer
584 views

Reconnecting to remote kernels through SSH tunnelling

This is a follow up question to How can I connect to a remote machine? and the excellent answer provided by ybeltukov. My system is now configured as described in the answer with my MacBook running ...
user avatar
  • 241
4 votes
1 answer
435 views

Convert C program using mathlink to WSTP

I have been using heavily a custom frontend to mathematica based on mathlink. I derived it from http://library.wolfram.com/infocenter/Demos/174/frontend.c?file_id=4692 . I just learned that mathlink ...
user avatar
  • 1,630
9 votes
1 answer
376 views

Suppress Mathematica Kernel taskbar tab when using .NETLink

Is there a possibility to suppress the Mathematica Kernel taskbar tab when accessing it through .NETLink on Windows?
user avatar
  • 93
7 votes
1 answer
204 views

Throwing away all expression on a loopback link

What is the simplest way to throw away all expressions waiting to be read on a loopback link, effectively resetting the link? I am building an expression on a loopback link using the C MathLink ...
user avatar
  • 227k
6 votes
1 answer
205 views

Wrapping a C library with a streaming interface

I've tried to give this a generic title to help future searchers, but concretely I am trying to parse YAML data. Import doesn't seem to support it natively and I ...
user avatar
  • 720
9 votes
1 answer
459 views

How can I wrap a C++ object in WSTP?

I am trying to wrap a sophisticated C/C++ API in Mathematica using WSTP, but can't work out how to return a pointer to a C/C++ data structure. This object was created on the C/C++ side of the wrapper, ...
user avatar
  • 126
2 votes
2 answers
210 views

Where to place the essential WSTP files in Visual Studio 2019?

I have Visual Studio for C installed in : C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC From https://reference.wolfram.com/language/tutorial/WSTPDeveloperGuide-Windows.html : "...
user avatar
18 votes
1 answer
1k views

Calling Mathematica from Visual Studio - example

I am trying to set up a connection between Visual Studio 10 and Mathematica 8.0 on a Windows system. I found several sources of information on the Wolfram website, but I get entirely lost. Most of the ...
user avatar
  • 183
14 votes
3 answers
2k views

Using LinkSnooper for monitoring the communication with an installable MathLink program

How can I monitor the communication between an installable MathLink program and the kernel? Can LinkSnooper do this?
user avatar
  • 227k
19 votes
1 answer
424 views

Control Front End in "mathlink" mode

Note: This question was already posted in the Wolfram community. In a terminal math session, we can start a front end (FE) easily by launching it though ...
user avatar
  • 111k
18 votes
3 answers
5k views

Write C/C++ programs calling Mathematica functions

I need to write a C/C++ program and call some functions in Mathematica especially those like Solve or NDSolve. The problem is ...
user avatar
  • 421
11 votes
3 answers
25k views

MathLink linking error after OS X 10.9 (Mavericks) upgrade

After macosx 10.9 mavericks upgrade i have a compilation problem, you can see below. Even the examples given in /Applications/Mathematica.app/SystemFiles/Links/MathLink/DeveloperKit/MacOSX-x86-64/...
user avatar
8 votes
1 answer
469 views

Has anybody been able to build WSTP applications under Visual Studio 2015's IDE?

I recently picked up an old project involving WSTP (formerly MathLink) programs, and as a starting place tried to get the demos provided by Wolfram to compile. The instructions were dated, referring ...
user avatar
8 votes
1 answer
403 views

Type conversion: LibraryLink mint vs. MathLink integer type

Assume the following situation: I have a WolframLibrary function which gets as parameter an integer tensor (which is for simplicity of rank 1) and the function should return an integer list through ...
user avatar
  • 111k
4 votes
2 answers
628 views

Cannot call custom function loaded from script using C/C++ MathLink

I am using MathLink with C/C++ on a Unix system in order to call a Mathematica (version 9) function and get the result. The function I need to call is a personal function of mine ...
user avatar
  • 421
8 votes
1 answer
172 views

Pass symbols through MathLink with full context information

How can I ensure that symbols passed through MathLink retain their full context information? When using MathLink naively, they do not. Demonstration, controlling another kernel: ...
user avatar
  • 227k
7 votes
1 answer
218 views

Tools for MathLink traffic analysis?

I noticed that the documentation for LinkSnooper says that it is "obsolete". I don't have any experience with this tool, but I thought it looked interesting after seeing results it was able to provide ...
user avatar
  • 4,251
3 votes
2 answers
596 views

MathLink and CDF

So far I have read that some things are not supported in CDFs. Istvan-zachar mentioned very useful things in his post. Unfortunately he mentioned that MathLink operations, including J/Link and .NET/...
user avatar
  • 6,340
1 vote
0 answers
130 views

Set form of all output to InputForm

I try to interact with mathematica using MathLink for symbolic computations. By default it returns strings such as 2\012-1 + E\012-------\012 3\012 E if the ...
user avatar
  • 1,630
1 vote
2 answers
398 views

MathLink Graphical Output (Plots) to File

In a custom Mathematica frontend based on MathLink I try to make use of plots produced in Notebooks. The idea is to write them to files whenever they get produced. According to C-code snippets I ...
user avatar
  • 1,630
14 votes
1 answer
1k views

How to run an external program in parallel with a Mathematica package?

Under Mathematica 8 (Linux x84_64) I was able to run an external program in parallel from a Mathematica package. However this procedure breaks down under Mathematica 9. Within my Mathematica package ...
user avatar