The example in the documentation for getWSLINK says

WSLINK link = libData->getWSLINK(libData);


#include "wstp.h"
#include "WolframLibrary.h"

EXTERN_C DLLEXPORT int testf(WolframLibraryData libdata, mint argc, MArgument* args, MArgument res)
    WSLINK link = libdata->getWSLINK(libdata);
    return LIBRARY_NO_ERROR;

results in an

error: cannot initialize a variable of type 'WSLINK' (aka 'WSLink *') with an rvalue of type 'MLINK' (aka 'MLINK_STRUCT *')

and indeed, in WolframLibrary.h getWSLINK is declared as

MLINK (*getWSLINK)(WolframLibraryData);

What's going on? I wanted to use WSLINK instead of MLINK because the documentation states that the latter is deprecated.

I am using Mathematica 10.4.1 on MacOSX-x86-64 (OS X 10.10.5).

  • $\begingroup$ Since you seem to be doing advanced LibraryLink programming, you might be interested in my LTemplate package. With LTemplate only ML-names can be used as I never put in the effort to try and see if WS-names can at all be forced with LibraryLink. $\endgroup$ – Szabolcs May 24 '16 at 9:03

Use mathlink.h with LibraryLink, not wstp.h. Use the ML prefix functions, not the WS prefix ones.

"MathLink" and "WSTP" are the very same thing, with absolutely no difference in functionality. MathLink was renamed to WSTP for marketing reasons when Mathematica 10 was released. As part of the renaming, ML-prefix functions were renamed to WS-prefix ones, which makes WSTP incompatible with MathLink (in the sense that you can't mix functions from one and the other). Thus now Mathematica ships with two libraries, which do exactly the same thing, but use different naming and are thus incompatible.

MathLink is considered deprecated, but it seems it's still what's needed for LibraryLink. If you open the MathKernel executable (i.e. Mathematica kernel) with a hex editor, you'll also see ML-prefix names, not WS-prefix ones.

If you use ML-prefix functions, you also get source compatibility with earlier versions of Mathematica (unless you use newly added features).

At this moment, I don't see the advantage of using WS-prefix names from a technical perspective, only disadvantages. Of course there's the risk that MathLink will really be removed in the next version (since it's stated to be deprecated), but given the current state of affairs, it seems unlikely ...



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.