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


MLINK MLOpenArgcArgv(MLENV env, int argc, char** argv, int* errno)
opens a MathLink connection, taking parameters from command-line arguments.
  • MLOpenArgcArgv() processes the command-line arguments and uses them to control the creation of the link.
  • MLOpenArgcArgv() recognizes the following command-line arguments:
"-linkconnect"connect to an existing link (LinkConnect)
"-linkcreate"create a link (LinkCreate)
"-linklaunch"launch a child process (LinkLaunch)
"-linkname","name"the name to use in opening the link
"-linkprotocol","protocol"the link protocol to use (TCPIP, Pipes, SharedMemory, etc.)
  • MLOpenArgcArgv() is not sensitive to the case of argument names.
  • MLOpenArgcArgv() ignores argument names that it does not recognize.
  • MLOpenArgcArgv() is called automatically by the MLMain() function created by mprep and mcc.
  • On some computer systems, giving 0 for argc or a null pointer for argv will cause arguments to be requested interactively, typically through a dialog box.
  • MLOpenArgcArgv() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* create a link using command-line parameters */

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 */ }

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

    /* ... */


    return 0;