This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


is a MathLink type representing a MathLink library environment.
  • The MathLink environment object stores the global state of MathLink during the execution of a program.
  • MLENV is defined in the file mathlink.h, which should be included in the source code for any MathLink-compatible program.
  • Each MathLink program must create a MLENV object before accessing any other MathLink functionality.
  • MLENV is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

int main(int argc, char **argv)
    MLENV env;
    MLINK link;
    int error;

    env = MLInitialize((char *)0);
    if(env (MLENV)0)
        { /* unable to initialize the MathLink environment */ }

    link = MLOpenArgcArgv(env, argc, argv, &error);
    if(link (MLINK)0 || error MLEOK)
        { /* unable to create the link */ }

    /* ... */

    return 0;