Get Started on Linux*
Before You Begin
Set Environment VariablesBefore you can use the compiler, you must first set the environment variables by sourcing the environment script using the initialization utility. This initializes all the tools in one step.
- Determine your installation directory,<install_dir>:
- If your compiler was installed in the default location by a root user or sudo user, the compiler will be installed under/opt/intel/oneapi. In this case, <install_dir> is /opt/intel/oneapi.
- For non-root users, your home directory under intel/oneapi is used. In this case, <install_dir> will be $HOME/intel/oneapi.
- For cluster or enterprise users, your admin team may have installed the compilers on a shared network file system. Check with your local admin staff for the location of installation (<install_dir>).
- Source the environment-setting script for your shell:
- bash: source <install_dir>/setvars.sh intel64
- csh/tcsh: source <install_dir>/setvars.csh intel64
You can develop oneAPI applications using C++ and SYCL* that will 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.
- To use an NVIDIA GPU, install the oneAPI for NVIDIA GPUs plugin.
Option 1: Use the Command Line
The Intel® oneAPI DPC++/C++ Compiler provides multiple drivers:
Language | Linux Drivers | Windows Drivers | Option Style | Notes |
---|---|---|---|---|
C |
icx icx-cc |
icx-cc |
Linux-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 |
Linux-style |
icpx is the recommended default C++ driver for Linux. If you use icpx with a C source file, it is compiled as an C++ file. Use icpx to link C++ object files. |
C/C++ |
icx-cl |
icx icx-cl |
Windows-style |
icx is the recommended default driver for Windows. icx-cl is the Microsoft-compatible variant of icx. On Linux, icx-cl requires the Microsoft Visual Studio package. |
Invoke the compiler 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 NVIDIA or AMD GPU, refer to the corresponding GPU plugin get started guide for detailed compilation instructions:
Option 2: Use 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
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:
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.