ILOG CPLEX 10.1 User's Manual > Programming Considerations > Licensing an Application > Examples |
Examples |
INDEX
![]() |
Here are some code samples that illustrate the use of those runtime license routines and methods. The first example illustrates the routine CPXputenv
when opening the CPLEX environment.
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);
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); }
Here is an example using Concert Technology for .NET users:
Cplex.Putenv("ILOG_LICENSE_FILE=../../../certify/access.e.ilm"); try { cplex = new Cplex(); } catch (ILOG.Concert.Exception e) { System.Console.WriteLine("Concert exception caught: " + e); } |
The following is an example showing how to use the routine CPXRegisterLicense
.
static char *ilm_license=\ "LICENSE ILOG Incline\n\ RUNTIME CPLEX 9.200 21-Jul-2005 R81GM34ECZTS N , 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; }
Here is an example for Java users applying IloCplex.registerLicense
:
static String ilm_CPLEX_license= "LICENSE ILOG Test\n RUNTIME CPLEX 9.200 021-Jul-2005 R81GM34ECZTS N , 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); } }
Here is an example for .NET users applying Cplex.RegisterLicense
:
Copyright © 1987-2006 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |