Programming Guide

Contents

Use the setvars Script with Windows*

Most of the component tool folders contain an environment script named
vars.bat
that configures the environment variables needed by that component to support oneAPI development work. For example, in a default installation, the
ipp
vars script on Windows is located at:
C:\Program Files (x86)\Intel\oneAPI\ipp\latest\env\vars.bat
. This pattern is shared by all oneAPI components that include an environment
vars
script.
These component tool
vars
scripts can be called directly or collectively. To call them collectively, a script named
setvars.bat
is provided in the oneAPI installation folder. For example, in a default installation on a Windows machine:
C:\Program Files (x86)\Intel\oneAPI\setvars.bat
.
Running the
setvars.bat
script without any arguments causes it to locate and run all of the
<component>\latest\env\vars.bat
scripts installed on the system. Changes made to the environment using the Windows
set
command can be seen after running these scripts.
Visual Studio Code* developers can install an extension to have
setvars.bat
run automatically. Learn more in Using Visual Studio Code with Intel oneAPI Toolkits.
Changes to your environment made by running the
setvars.bat
script (or the individual
vars.bat
scripts) are not permanent. Those changes only apply to the
cmd.exe
session in which the
setvars.bat
environment script was executed.

Command Line Arguments

The
setvars.bat
script supports several command-line arguments, which is displayed using the
--help
option. For example:
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" --help
Important arguments include the
--config=file
argument and the ability to include additional arguments that will be passed to the
vars.bat
scripts that are called by the
setvars.bat
script.
The
--config=file
argument provides the ability to limit environment initialization to a specific set of oneAPI components, as well as providing a way to initialize the environment for a specific component version. For example, to limit environment setup just the Intel® Integrated Performance Primitives (Intel® IPP) library and the Intel® oneAPI Math Kernel Library (oneMKL), create a config file that tells the
setvars.bat
script to only configure the environment variables for those two oneAPI components. More details and examples are provided in Use a Config file for setvars.bat on Windows.
Any extra arguments passed on the
setvars.bat
command line that are not described in the
setvars.bat
help message will be passed to every called
vars.bat
script. That is, if the
setvars.bat
script does not recognize an argument, it assumes the argument is meant for use by one or more component vars scripts and passes those extra arguments to every component
vars.bat
script that it calls. The most common extra arguments are the
ia32
and
intel64
arguments, which are used by the Intel compilers and the Intel IPP and oneMKL libraries to indicate the application target architecture.
If both Microsoft Visual Studio* 2017 and Visual Studio 2019 are installed on your system, you can specify which of these two Visual Studio environments should be initialized as part of the oneAPI environment initialization by adding either the
vs2017
or the
vs2019
argument to the
setvars.bat
command line. By default, the most recent version of Visual Studio is located and initialized.
Inspect the individual
vars.bat
scripts to determine which, if any, command line arguments they accept.

How to Run

<install-dir>\setvars.bat

How to Verify

After executing
setvars.bat
, verify success by searching for the SETVARS_COMPLETED environment variables. If
setvars.bat
was successful, SETVARS_COMPLETED will have a value of 1:
set | find "SETVARS_COMPLETED"
Return value
SETVARS_COMPLETED=1
If the return value is anything other than
SETVARS_COMPLETED=1
, then the test failed and
setvars.bat
did not complete properly.

Multiple Runs

Because many of the individual
env\vars.bat
scripts make significant changes to PATH, CPATH, and other environment variables, the top-level
setvars.bat
script will not allow multiple invocations of itself in the same session. This is done to ensure that your environment variables do not become too long due to redundant path references, especially the
%PATH%
environment variable.
This can be overridden by passing
setvars.bat
a
--force
flag. In this example, the user tries to run
setvars.bat
twice. The second instance is stopped because
setvars.bat
has already been run.
> <install-dir>\setvars.bat :: initializing environment ... (SNIP: lot of output) :: oneAPI environment initialized ::
> <install-dir>\setvars.bat :: WARNING: setvars.bat has already been run. Skipping re-execution. To force a re-execution of setvars.bat, use the '--force' option. Using '--force' can result in excessive use of your environment variables.
In the third instance, the user runs
<install-dir>\setvars.bat --force
and the initialization is successful.
> <install-dir>\setvars.bat --force :: initializing environment ... (SNIP: lot of output) :: oneAPI environment initialized ::

ONEAPI_ROOT Environment Variable

The
ONEAPI_ROOT
variable is set by the top-level
setvars.bat
script when that script is sourced. If there is already a
ONEAPI_ROOT
environment variable defined,
setvars.bat
overwrites it. This variable is primarily used by the
oneapi-cli
sample browser and the Microsoft Visual Studio and Visual Studio Code* sample browsers to help them locate oneAPI tools and components, especially for locating the
setvars.bat
script if the
SETVARS_CONFIG
feature has been enabled. For more information on the
SETVARS_CONFIG
feature, see Automate the setvars.bat Script with Microsoft Visual Studio*.
On Windows systems, the installer adds the
ONEAPI_ROOT
variable to the environment and no additional user action is required.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.