Building and linking programs / Environment variables |
Environment variables define the environment used by the compiler and executables launched from Project Manager. Where and when the environment variable is important.
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):
The order of priority allows you to override both system environment variables (6, above) or environment variables defined in a Genero Studio configuration (5, above) by setting them in Project Manager (1 through 4, above).
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:
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" |
In this example, the program node in the project has a library node as a dependency. The environments have been defined as shown:
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