Get Started on Windows*
Before You Begin
Set Environment VariablesThe compiler integrates into the following versions of Microsoft Visual Studio*:
- Visual Studio 2022
- Visual Studio 2019
Visual Studio Community Edition or higher is required for full functionality within Visual Studio, including debugging and development. Visual Studio Express Edition allows only command-line builds. For all versions of Visual Studio, Microsoft C++ support must be selected as part of the Visual Studio install. For Visual Studio 2017 and later, you must use a custom install to select this option.
You typically do not need to set the environment variables on Windows, as the compiler command-line window sets these variables for you automatically. If you need to set the environment variables, run the environment script as described in Use the setvars and oneapi-vars Scripts with Windows*.
Install GPU Drivers (Optional)To develop and run applications for Intel GPUs you must first install the latest Intel GPU drivers.
Option 1: Use the Command Line in Microsoft Visual Studio
The Intel® oneAPI DPC++/C++ Compiler provides multiple drivers that can be used to invoke the compiler from the command line. Use the driver appropriate for your specific project.
Language | Compiler Driver for Linux | Compiler Driver for Windows | Option Style | Notes |
---|---|---|---|---|
C |
icx icx-cc |
icx-cc |
Clang-style |
icx is the recommended default C driver for Linux. If you use icx with a C++ source file, it is compiled as a C++ file. Use icx to link C object files. icx-cc is the Microsoft-compatible variant of icx. |
C++ |
icpx | icpx |
Clang-style |
icpx is the recommended default C++ driver for Linux. If you use icpx with a C source file, it is compiled as a C++ file. Use icpx to link C++ object files. |
C/C++ |
icx-cl (see notes) |
icx icx-cl |
MSVC-style |
icx is the recommended default driver for Windows. icx-cl is the Microsoft-compatible variant of icx.
NOTE:
On Linux, icx-cl is experimental and requires the Microsoft Visual Studio Package.
|
Invoke the compiler on the command line using the following syntax:
{compiler driver} [option] file1 [file2...]To invoke the compiler using the command line from within Microsoft Visual Studio, open a command prompt and enter your compilation command. For example:
icx hello-world.cpp
For SYCL compilation, use the -fsycl option with the C++ driver:
icx -fsycl hello-world.cpp
Option 2: Use Microsoft Visual Studio
Project Support for the Intel® DPC++/C++ Compiler in Microsoft Visual Studio
New Microsoft Visual Studio projects for DPC++ are automatically configured to use the Intel® oneAPI DPC++/C++ Compiler.
New Microsoft Visual C++* (MSVC) projects must be manually configured to use the Intel® oneAPI DPC++/C++ Compiler.
Use the Intel® DPC++/C++ Compiler in Microsoft Visual Studio
Exact steps may vary depending on the version of Microsoft Visual Studio in use.
- Create a Microsoft Visual C++ (MSVC) project or open an existing project.
- In Solution Explorer, select the project(s) to build with the Intel® oneAPI DPC++/C++ Compiler.
- Open Project > Properties .
- In the left pane, expand the Configuration Properties category and select the General property page.
- In the right pane change the Platform Toolset to the compiler you want to use:
- For C++ with SYCL, select Intel® oneAPI DPC++ Compiler.
- For C/C++, there are two toolsets.
Select Intel C++ Compiler <major version> (example 2021) to invoke icx.
Select Intel C++ Compiler <major.minor> (example 19.2) to invoke icl.
Alternatively, you can specify a compiler version as the toolset for all supported platforms and configurations of the selected project(s) by selecting Project > Intel Compiler > Use Intel oneAPI DPC++/C++ Compiler.
- Rebuild, using either Build > Project only > Rebuild for a single project or Build > Rebuild Solution for a solution.
Select Compiler Version
If you have multiple versions of the Intel® oneAPI DPC++/C++ Compiler installed, you can select which version you want from the Compiler Selection dialog box:
- Select a project, then go to Tools > Options > Intel Compilers and Libraries > <compiler> > Compilers, where <compiler> values are C++ or DPC++.
- Use the Selected Compiler drop-down menu to select the appropriate version of the compiler.
- Select OK.
Switch Back to the Microsoft Visual Studio C++ Compiler
If your project is using the Intel® oneAPI DPC++/C++ Compiler, you can choose to switch back to the Microsoft Visual C++ compiler:
- Select your project in Microsoft Visual Studio.
- Right-click and select Intel Compiler > Use Visual C++ from the context menu.
This action updates the solution file to use the Microsoft Visual Studio C++ compiler. All configurations of affected projects are automatically cleaned unless you select Do not clean project(s). If you choose not to clean projects, you will need to rebuild updated projects to ensure all source files are compiled with the new compiler.
Build a Program From the Command Line
Use the following steps to test your compiler installation and build a program.
- Use a text editor to create a file called hello-world.cpp with the following contents:
#include <iostream> int main() { std::cout << "Hello, world!\n"; return 0; }
- Compile hello-world.cpp:
icx hello-world.cpp
- Now you have an executable called hello-world.exe which can be run and will give immediate feedback:
hello-world.exe
Which outputs:Hello, world!
You can direct and control compilation with compiler options. For example, you can create the object file and output the final binary in two steps:
- Compile hello-world.cpp:
icx hello-world.cpp /c /Fohello-world.obj
The /c option prevents linking at this step and /Fo specifies the name for the object file. - Use the icx compiler to link the resulting application object code and output an executable:
icx hello-world.obj /Fehello-world.exe
The /Fe option specifies the generated executable file name.
Refer to Compiler Options for details about available options.