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


MLENV MLInitialize(char* p)
initializes the MathLink environment object and passes parameters in p.
  • The MathLink environment object stores the global state of MathLink during the execution of a program.
  • A program can install custom memory allocators using the parameters object p.
  • An appropriate call to MLInitialize() is generated automatically when an external program is created from MathLink templates.
  • Any external program that uses the MathLink library must call MLInitialize() before calling any other MathLink library functions.
  • The MathLink environment functions as a factory to create link objects.
  • MLInitialize() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

int main(int argc, char **argv)
    MLENV ep;
    MLINK lp;
    int error;

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

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

    /* ... */

    return 0;