Routines Used for Licensing

All ILOG CPLEX applications either call the CPXopenCPLEX() routine to establish the CPLEX environment, or use the IloCplex constructor to initialize ILOG CPLEX for use with Concert Technology. Until either CPXopenCPLEX() is called or the IloCplex object exists, few ILOG CPLEX routines operate. In addition to allocating the environment, CPXopenCPLEX() performs license checks, as does the constructor for the IloCplex object. For development licenses, no additional licensing steps are required. For runtime licenses, your application first needs to provide some additional licensing information before the call to CPXopenCPLEX() or the use of an IloCplex constructor. For RTNODE, RTSTOKEN and TOKEN keys, this requires calling the CPXputenv() routine from the Callable Library and C++ Concert, or the IloCplex.putenv() static method from Java, to specify the location of the key through the ILOG_LICENSE_FILE environment variable. For memory-based RUNTIME keys, this requires calling the CPXRegisterLicense() routine for Callable Library and C++ users, or the static method IloCplex.registerLicense() for Java users, to pass the RUNTIME key to ILM.

Descriptions of the CPXputenv() and CPXRegisterLicense() routines are in the ILOG CPLEX Reference Manual; descriptions of IloCplex.putenv() and IloCplex.registerLicense() are in the ILOG CPLEX Java Reference Manual.

Examples

Here are some code samples that illustrate the usage of the above runtime license routines. The first example illustrates usage of the CPXputenv() routine when opening the CPLEX environment.

CPXputenv Routine

  char *inststr = NULL;
  char *envstr  = NULL;
  
  /* Initialize the CPLEX environment */
  
  envstr = (char *) malloc (256);
  if ( envstr == NULL ) {
     fprintf (stderr, "Memory allocation for CPXputenv failed.\n");
     status = FAIL;
     goto TERMINATE;
  }
  else {
     inststr = (char *)  getenv("MYAPP_HOME");
     if ( inststr == NULL ) {
        fprintf (stderr, "Unable to find installation directory.\n");
        status = FAIL;
        goto TERMINATE;
     }
     strcpy (envstr, "ILOG_LICENSE_FILE=");
     strcat (envstr, inststr);
     strcat (envstr, "\\license\\access.ilm");
     CPXputenv (envstr);
  }
  
  env = CPXopenCPLEX (&status);
  

The putenv Routine for Java Users

Here is an example using Concert Technology for Java users:

  IloCplex.putenv("ILOG_LICENSE_FILE=\\license\\access.ilm");
  try {
     cplex = new IloCplex();
  }
  catch (IloException e) {
     System.err.println("Exception caught for runtime license:" + e);
  }
  

CPXRegisterLicense Routine

The following is an example illustrating the usage of the CPXRegisterLicense() routine.

  static char *ilm_license=\
   "LICENSE ILOG Incline\n\
    RUNTIME CPLEX      8.000 21-Apr-2002 R81GM34ECZTS N IRIX , options: m ";
  static int ilm_license_signature=2756133;
  
     CPXENVptr     env = NULL;
     int           status;
  
     /* Initialize the CPLEX environment */
  
      status = CPXRegisterLicense (ilm_license, ilm_license_signature);
      if ( status != 0) {
         fprintf (stderr, "Could not register CPLEX license, status %d.\n",
                  status);
         goto TERMINATE;
      }
      env = CPXopenCPLEX (&status);
      if ( env == NULL ) {
         char  errmsg[1024];
         fprintf (stderr, "Could not open CPLEX environment.\n");
         CPXgeterrorstring (env, status, errmsg);
         fprintf (stderr, "%s", errmsg);
         goto TERMINATE;
      }
  

The registerLicense Routine for Java Users

Here is an example using IloCplex.registerLicense, for Java users:

  static String ilm_CPLEX_license=
  "LICENSE ILOG Test\n RUNTIME CPLEX      8.000 021-Apr-2002 R81GM34ECZTS N IRIX ,
  options: m ";
  static int ilm_CPLEX_license_signature=2756133;
  
  public static void main(String[] args) {
  
     try {
        IloCplex.registerLicense(ilm_CPLEX_license, ilm_CPLEX_license_signature);
        IloCplex cplex = new IloCplex();
     }
     catch (IloException e) {
        System.err.println("Exception caught for runtime license:" + e);
     }
  }


Previous Page: Types of ILM Runtime Licenses  Return to Top Next Page: Summary