What determines the value of an environment variable

Environment variables define the environment used by the compiler and executables launched from Project Manager. Where and when the environment variable is set is important.

Order of precedence

An environment variable can be set in multiple places, inside and outside of Genero Studio. Environment variables have an order of priority (high to low):

  1. Environment variables defined for the node. This has the highest priority. A node's environment variables are set using the Advanced Properties dialog.
  2. The environment of the node's parents (ancestors).
  3. The environment of the node's dependencies.
  4. Build rule environment variables for the project for the current language of the node. See Add a project-level environment variable.
  5. Build rule environment variables for the specific setup for the current language of the node. See Add a specific setup-level environment variable
  6. Build rule environment variables for the global for the current language of the node. See Add a global-level environment variable.
  7. Environment variables defined in Environment sets.
  8. System environment variables. These have the lowest priority.

Order within an Environment Set

Within an Environment Set, Arrow keys can be used to change the order of the variables defined. This affects the way the variables are interpreted when the program is executed. For example:

Table 1. Variable interpretation examples
Project level Variables definition and order Result when application is executed
Project V1="hello"
Application V2="$(V1) world"

V1="goodbye"

V1="goodbye"

V2="hello world"

Application

V1="goodbye"

V2="$(V1) world"

V1="goodbye"

V2="goodbye world"

Note: If a foreign language Language support (text encoding) is selected in Genero Studio preferences, the LANG variable must be set appropriately to correspond to the selected encoding. Set the variable for a specific environment set in Genero Studio configurations (Tools>>Configurations).

Example: Priority and Environment Variables

In this example, the program node in the project has a library node as a dependency. The environments have been defined as shown:

Table 2. Environment Set for levels used in the example
Level Environment Set
System environment
PATH=/bin;/usr/bin 
VAR1=hello 
VAR2=bonjour 
VAR3=guten tag
My Library Environment
PATH=$(PATH);$(ProjectDir)/scripts 
VAR1=goodbye
My Program Environment
PATH=$(PATH);$(ProjectDir)/scripts 
VAR1=$(VAR1) world 
VAR2=$(VAR2) $(VAR1)

If the project directory $(ProjectDir) is set to "/home/joe/project", the environment for the program will be:

PATH=/bin;/usr/bin/;/home/joe/project/scripts 
VAR1=goodbye world 
VAR2=bonjour goodbye world 
VAR3=guten tag