### Working with Environment Variables

To use the command-line tools, you must change several environment variables. If you are using Carbide command-line tools with Microsoft® Windows®, you can assign environment variables through the Environment tab under the System control panel in Windows XP/2000/NT.

#### CWFolder Environment Variable

Use the following syntax when defining variables in batch files or on the command line:

set CWFolder=C:\Program Files\Carbide

In this example, CWFolder refers to the path where you installed Carbide. It is not necessary to include quotation marks when defining environment variables that include spaces. Because Windows does not strip out the quotes, this leads to unknown directory warnings.

#### Setting the PATH Environment Variable

The PATH variable should include the paths for the tools, as shown below. For other tools, the paths can vary. An example of setting PATH:

%CWFolder%\Carbide
%CWFolder%\Carbide\Carbide.c++

The first path contains the FlexLM license manager DLL, and the second path contains the tools. To run FlexLM, copy the following file into the directory containing the command-line tools:

..\Carbide\license.dat

Or, you can define the variable LM_LICENSE_FILE as:

%CWFolder%\license.dat

which points to the license information. It might point to alternate versions of this file, as needed.

#### Getting Environmental Variables

Use the predefined macro __env_var() to return host-specific environmental variables. An example of getting an environmental variable:

// returns "username" environmental variable
// (host-specific)
char* username = __env_var(username);

#### Search Path Environment Variables

Several environment variables are used at runtime to search for system include paths and libraries that can shorten command lines for many tasks. All of the variables mentioned here are lists that are separated by semicolons (;) in Windows and colons (:) in Solaris.

For the linker, unless you specify -nodefaults or -disassemble, the linker searches the environment for a list of system access paths and library files to be added to the end of the search and link orders. For example, with Embedded PowerPC, the linkers searches for files, libraries, and command files, using the system library paths found within the variables MWEABIPPCLibraries and MWLibraries. Associated with these lists are MWEABIPPCLibraryFiles and MWLibraryFiles, which contain lists of libraries (or object files or command files) to add to the end of the link order. These files can be located in any of the cumulative access paths at runtime.

If you are only building for one target, you can use MWCIncludes, MWAsmIncludes, MWLibraries, and MWLibraryFiles. Because the target-specific versions of these variables override the generic variables, they are useful when working with multiple targets. If the target-specific variable exists, then the generic variable is not used because you cannot combine the contents of the two variables.