This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MATHEMATICA LIBRARYLINK C FUNCTION|Tutorials »

getMathLink


gets a MathLink connection to use for evaluations in Mathematica.
  • Used in C/C++ code in a library function called from Mathematica.
  • The link returned by is a loopback link.
The following gets a MathLink connection and uses it to send a message to the kernel:
The following gets a MathLink connection and uses it to send a message to the kernel:
    MLINK link = libData->getMathLink(libData);
    MLPutFunction( link, "EvaluatePacket", 1);
    MLPutFunction( link, "Message", 2);
    MLPutFunction( link, "MessageName", 2);
    MLPutSymbol( link, "MyFunction");
    MLPutString( link, "info");
    MLPutString( link, "Message called from within DLL function.");
    libData->processMathLink( link);
    pkt = MLNextPacket( link);
    if ( pkt == RETURNPKT) {
        MLNewPacket(link);
    }