ILOG CPLEX 11.0 Getting Started > Tutorials > Callable Library Tutorial > How ILOG CPLEX Works > Opening the ILOG CPLEX Environment

ILOG CPLEX requires a number of internal data structures in order to execute properly. These data structures must be initialized before any call to the ILOG CPLEX Callable Library. The first call to the ILOG CPLEX Callable Library is always to the function CPXopenCPLEX. This routine checks for a valid ILOG CPLEX license and returns a pointer to the ILOG CPLEX environment. This pointer is then passed to every ILOG CPLEX Callable Library routine, except those, such as CPXmsg, which do not require an environment.

The application developer must make an independent decision as to whether the variable containing the environment pointer is a global or local variable. Multiple environments are allowed, but extensive opening and closing of environments may create significant overhead on the licensor and degrade performance; typical applications make use of only one environment for the entire execution, since a single environment may hold as many problem objects as the user wishes. After all calls to the Callable Library are complete, the environment is released by the routine CPXcloseCPLEX. This routine indicates to ILOG CPLEX that all calls to the Callable Library are complete, any memory allocated by ILOG CPLEX is returned to the operating system, and the use of the ILOG CPLEX license is ended for this run.