Programming Guide

Contents

Automate the setvars.bat Script with Microsoft Visual Studio*

Support for Microsoft Visual Studio* 2017 is deprecated as of the Intel® oneAPI 2022.1 release, and will be removed in a future release.
The
setvars.bat
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.bat
script can also be run automatically when Microsoft Visual Studio is started. You can configure this feature to instruct the
setvars.bat
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 Microsoft Visual Studio. The variable has three conditions or states:
  • Undefined (the
    SETVARS_CONFIG
    environment variable does not exist)
  • Defined but empty (the value contains nothing or only whitespace)
  • Defined and points to a
    setvars.bat
    configuration file
If
SETVARS_CONFIG
is undefined there will be no attempt to automatically run
setvars.bat
when Visual Studio is started. This is the default case, since the
SETVARS_CONFIG
variable is not defined by the oneAPI installer.
If
SETVARS_CONFIG
is defined and has no value (or contains only whitespace), the
setvars.bat
script will be automatically run when Visual Studio is started. In this case, the
setvars.bat
script initializes the environment for
all
oneAPI tools that are installed on your system. For more information about running the
setvars.bat
script, see Build and Run a Sample Project Using the Visual Studio* Command Line.
When
SETVARS_CONFIG
is defined with the absolute pathname to a
setvars
configuration file, the
setvars.bat
script will be automatically run when Visual Studio is started. In this case, the
setvars.bat
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 Using a Config File with setvars.bat.
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 Visual Studio. (A plug-in that was added to Visual Studio when you installed the oneAPI tools on your Windows system performs the SETVARS_CONFIG actions; that is why Visual Studio must have access to the location and contents of the
setvars
configuration file.)
If you leave the
setvars
config file empty, the
setvars.bat
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 Using a Config File with setvars.bat 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 Visual Studio (per the rules above). You can define the
SETVARS_CONFIG
environment variable using the Windows SETX command or in the Windows GUI tool by typing
“rundll32.exe sysdm.cpl,EditEnvironmentVariables”
into the
“Win+R”
dialog (use “Win+R” to bring up the dialog).

Product and Performance Information

1

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