Automate the setvars.sh Script with Eclipse*
The
setvars.sh
script sets up the environment variables needed to use
the oneAPI toolkits. This script must be run every time a new terminal
window is opened for command-line development. The setvars.sh
script can
also be run automatically when Eclipse* is started. You can configure
this feature to instruct the setvars.sh
script to set up a specific set
of oneAPI tools by using the SETVARS_CONFIG
environment variable.SETVARS_CONFIG Environment Variable States
The
SETVARS_CONFIG
environment variable enables automatic
configuration of the oneAPI development environment when you start your
instance of Eclipse IDE for C/C++ Developers. The variable has three
conditions or states:- Undefined (theSETVARS_CONFIGenvironment variable does not exist)
- Defined but empty (the value contains nothing or only whitespace)
- Defined and points to asetvars.shconfiguration file
If
SETVARS_CONFIG
is undefined or if it exists but has no value (or
contains only whitespace), the setvars.sh
script will be automatically
run when Eclipse is started. In this case, the setvars.sh
script
initializes the environment for all
oneAPI tools that are installed on
your system. For more information about running the setvars.sh
script,
see Build and Run a Sample Project Using
Eclipse.When
SETVARS_CONFIG
is defined with the absolute pathname to a
setvars
configuration file, the setvars.sh
script will be
automatically run when Eclipse is started. In this case, the setvars.sh
script initializes the environment for only those oneAPI tools that are
defined in the setvars
configuration file. For more information
about how to create a setvars config file, see Use a Config file for
setvars.sh on Linux or
macOS.
The default
SETVARS_CONFIG
behavior in Eclipse is different than
the behavior described for Visual Studio on Windows. When starting
Eclipse, automatic execution of the setvars.sh
script is always
attempted. When starting Visual Studio automatic execution of the
setvars.bat
script it is only attempted if the SETVARS_CONFIG
environment variable has been defined. A
setvars
configuration file can have any name and can be saved to
any location on your hard disk, as long as that location and the file
are accessible and readable by Eclipse. (A plug-in that was added to
Eclipse when you installed the oneAPI tools on your LInux system
performs the SETVARS_CONFIG
actions; that is why Eclipse must have
access to the location and contents of the setvars
configuration
file.)If you leave the
setvars
config file empty, the setvars.sh
script
will initialize your environment for all
oneAPI tools that are
installed on your system. This is equivalent to defining the
SETVARS_CONFIG
variable with an empty string. See Use a Config file
for setvars.sh on Linux or
macOS for details
regarding what to put inside of your setvars config file.Define the SETVARS_CONFIG Environment Variable
Since the
SETVARS_CONFIG
environment variable is not automatically
defined during installation, you must add it to your environment before
starting Eclipse (per the rules above). There are a variety of places to
define the SETVARS_CONFIG
environment variable:- /etc/environment
- /etc/profile
- ~/.bashrc
- and so on…
The list above shows common places to define environment variables on a
Linux system. Ultimately, where you choose to define the SETVARS_CONFIG
environment variable depends on your system and your needs.