Get Started on Linux*
Before You Begin
Set Environment Variables for CLI Development
The Unified Directory Layout was implemented in 2024.0. If you have multiple toolkit versions installed, the Unified layout ensures that your development environment contains the correct component versions for each installed version of the toolkit.
The directory layout used before 2024.0, the Component Directory Layout, is still supported on new and existing installations.
For detailed information about the Unified layout, including how to initialize the environment and advantages with the Unified layout, refer to Use the setvars and oneapi-vars Scripts with Linux.
Compiler environment variables must first be configured if using the compiler from a Command Line Interface (CLI). Environment variables are set up with a script called setvars in the Component Directory Layout or oneapi-vars in the Unified Directory Layout. By default, changes to your environment made by sourcing the setvars.sh or oneapi-vars.sh script apply only to the terminal session in which the environment script was sourced. You must source the script for each new terminal session.
Detailed instructions on using the setvars.sh or oneapi-vars.sh script are found in Use the setvars and oneapi-vars Scripts with Linux.
Optionally use one-time setup for setvars.sh as described in Use Modulefiles with Linux*.
You can develop oneAPI applications using C++ and SYCL* that run on Intel, AMD*, or NVIDIA* GPUs.
To develop and run applications for specific GPUs, you must first install the corresponding drivers or plug-ins:
- To use an Intel GPU, install the latest Intel GPU drivers.
- To use an AMD GPU, install the oneAPI for AMD GPUs plugin from Codeplay.
- To use an NVIDIA GPU, install the oneAPI for NVIDIA GPUs plugin from Codeplay.
Invoke the Compiler from the Command Line
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...]
For example:
icpx hello-world.cpp
For SYCL compilation, use the -fsycl option with the C++ driver:
icpx -fsycl hello-world.cpp
If you are targeting an AMD or NVIDIA GPU, refer to the corresponding Codeplay plugin get started guide for detailed compilation instructions:
Invoke the Compiler From the Eclipse* CDT
Follow these steps to invoke the compiler from within the Eclipse* CDT.
Install the Intel® Compiler Eclipse CDT plugin.
- Start Eclipse
- Select Help > Install New Software
- Select Add to open the Add Site dialog
- Select Archive, browse to the directory <install_dir>/compiler/<version>/linux/ide_support, select the .zip file that starts with com.intel.dpcpp.compiler, then select OK
- Select the options beginning with Intel, select Next, then follow the installation instructions
- When asked if you want to restart Eclipse*, select Yes
Build a new project or open an existing project.
- Open Existing Project or Create New Project on Eclipse
- Right click on Project > Properties > C/C++ Build > Tool chain Editor
- Select Intel DPC++/C++ Compiler from the right panel
Set build configurations.
- Open Existing Project on Eclipse
- Right click on Project > Properties > C/C++ Build > Settings
- Create or manage build configurations in the right panel
Example: 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; }
- Open a terminal window.
- If you are not using one-time setup for setvars.sh, set environment variables by sourcing setvars:
Component Directory Layout
source <install-dir>/setvars.sh
Unified Directory Layout
source <install-dir>/<toolkit-version>/oneapi-vars.sh
For information about the <install-dir> location for Component or Unified layout on system-wide or private installations, refer to Using the setvars and oneapi-vars Scripts with Linux*. - From the terminal window, issue the following command to compile hello-world.cpp:
icpx hello-world.cpp -o hello-world
The -o option specifies the file name for the generated output. - Now you have an executable called hello-world, which can be run and will give immediate feedback:
hello-world
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:
icpx hello-world.cpp -c
The -c option prevents linking at this step. - Use the icpx compiler to link the resulting application object code and output an executable:
icpx hello-world.o -o hello-world
The -o option specifies the generated executable file name.
Refer to Compiler Options for details about available options.
© Codeplay Software Limited. Intel, the Intel logo, Codeplay, Codeplay logo and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.