1.11.3 Configuring environmental variables

CodeBlocks

[Contents] CodeBlocks Manual   [Search] Search

[Table of contents]

1.11.3 Configuring environmental variables


The configuration for an operating system is specified by so-called environmental variables. The environmental variable PATH for example contains the path to an installed compiler. The operating system will process this environmental variable from beginning to end, i.e. the entries at the end will be searched last. If different versions of a compiler or other applications are installed, the following situations can occur:
  • An incorrect version of a software is called
  • Installed software packages call each other
So it might be the case that different versions of a compilers or other tools are mandatory for different projects. One possibility in such a case is to change the environmental variables in the system control for every project. However, this procedure is error-prone and not flexible. For this requirement, CodeBlocks offers an elegant solution. Different configurations of environmental variables can be created which are used only internally in CodeBlocks. Additionally, you can switch between these configurations. The Figure 1.12 shows the dialogue which you can open via ’Environment Varibales’ under ’Settings’ /’Environment’ . A configuration is created via the ’Create’ button.

[Figure # 12]
Figure 1.12: Environmental variables

Access and scope of the environmental variables created here, is limited to CodeBlocks. You can expand these environmental variables just like other CodeBlocks variables via $(NAME).
Note:
A configuration for the environmental variable for each project can be selected in the context menu ’Properties’ of the ’EnvVars options’ tab.
Example
You can write the used environment into a postbuild Step (see section 1.6) in a file <project>.env and archive it within your project.
  cmd /c echo \%PATH\%  > project.env
or under Linux
  echo \$PATH > project.env


[Previous] 1.11.2  Data Exchange with other applications
[Next] 1.11.4  Switching between perspectives

Created: 2010/25/05 11:52   Updated: 2010/25/05 11:52
Author: HighTec EDV-Systeme GmbH
Copyright © 2010 HighTec EDV-Systeme GmbH