Environment Variables for Compiling

IBM C and C++ Compilers checks the operating system environment variables for path information and for the default values of compiler options.

Environment variables can be set from the command line.

Environment variables can be set from the command line or in the System window, by clicking on Set to add a new environment variable to the list of User Environment Variables.

The environment variables described here are the compiler environment variables. A number of environment variables are also used at run time.

DPATH Lists the directories that the compiler searches for message and help files.
HELP Lists the directories that the compiler searches for help (.hlp) files.
ICC Sets compiler options and filenames.
ILINK Sets options that the IBM C and C++ Compilers linker uses when it links the object files that the compiler generates. At link time, the options in this variable are processed before the options on the command line. If the compiler invokes the linker, any linker options specified through the compiler or the ICC variable are passed to the command line. If some options conflict, the option that was processed last takes effect.

Note: You cannot specify filenames in the ILINK environment variable. If you invoke the linker through the compiler, you can specify filenames for the linker in ICC.

INCLUDE Lists directories that the compiler searches for header files.
LIB Lists directories that the linker searches for library (.lib) files. This should include the directory that contains the IBM C and C++ Compilers libraries, and the directory that contains the Toolkit's KERNEL32.LIB file (on Windows) or OS2386.LIB file (on OS/2).
LIBPATH Lists directories that executables (including the compiler and linker) search for DLLs that they use to run.
LOCPATH Lists directories that the setlocale( ) function uses to locate locale data.
PATH Lists the directory or directories to be searched for executable files and DLLs when the compiler is invoked.
Lists the directory or directories to be searched for executable files when the compiler is invoked.

This variable should include the directories containing IBM C and C++ Compilers executables, for example the compiler (icc.exe) and linker (ilink.exe) executable files.

TMP Sets the directory where IBM C and C++ Compilers places all its temporary work files. This directory might also be used by other applications that generate temporary files. If this variable is undefined, the compiler uses the current directory. If you installed the compiler on a LAN, temporary files are stored in your local directory. The work files created by the compiler are normally erased at the end of compilation; however, if an interruption occurs during compiling, these work files may still exist after the compilation ends. If you set the TMP variable, you eliminate the possibility of work files being scattered around your file system.

Use the operating system SET command to give values to environment variables. Set the LIBPATH variable, and all DEVICE statements, in CONFIG.SYS. You can set other variables in any of three places:

CONFIG.SYS file Add a line that sets the environment variable to the value you want. For example,
  SET TMP=C:\IBMCPP\TMP

If the environment variable already exists in CONFIG.SYS, add the IBM C and C++ Compilers values to the existing variable.

Environment variables specified in CONFIG.SYS are in effect for every session you start. This is a good place to specify variables that you want to apply every time you compile.

SETENV.BAT file
or
SETENV.CMD file
The IBM C and C++ Compilers installation creates this command file. You must invoke this file in each session where you will use IBM C and C++ Compilers. The variables set by SETENV.CMD or SETENV.BAT are in effect only for the session or sessions in which it is invoked.

You can add environment variables of your choice to this file, to specify variables that you always use without having to type them individually on the command line. The variables in this file override environment variables in the CONFIG.SYS file. To avoid overriding values in CONFIG.SYS, append the original value of the variable using %variable%, as shown in this PATH statement:

   SET PATH=C:\IBMCXXW\BIN;%PATH%
   SET PATH=C:\IBMCXXO\BIN;%PATH%
command line When the SET command is used on the command line, the values you specify are in effect only for that session. They override values previously specified in CONFIG.SYS or SETENV.CMD/SETENV.BAT. You can append the original value of the variable using %variable%.

Example

This example could be used in the SETENV.CMD file or SETENV.BAT file, or on the command line. The following command adds this directory to the PATH variable:

   SET PATH=C:\IBMCXXW\BIN;%PATH%NEWDIR
   SET PATH=C:\IBMCXXO\BIN;%PATH%NEWDIR

This command makes C:\IBMCXXW\BIN (or C:\IBMCXXO\BIN) the first directory searched by the operating system after the current directory. To put the new directory at the end of the search sequence, put %PATH% before the new directory name.



Application Run-Time Environment Variables