Issue
A dependency issue may occur for C++ compilation through Intel® oneAPI compiler version 2023.0 on Linux* systems resulting in errors such as "fatal error: <C++ header> file not found".
This error may occur when:
- The required dependencies for the compiler are not installed. For example, g++ is not installed.
- There are multiple versions of the required dependencies installed and the compiler finds a mismatched gcc/g++ version on the system. For example, gcc 9/g++ 9 is installed alongside gcc 10, without the corresponding g++ 10.
The following shows an example of the error:
$ icpx vecadd.cpp -o vecadd vecadd.cpp:1:10: fatal error: 'iostream' file not found #include <iostream> ^~~~~~~~~~~ 1 error generated.
Current Workarounds
- Make sure the latest version of gcc installed on your machine also has the equivalent g++ package installed. For example, gcc 10 with g++ 10.
- If you prefer to override the Intel® compiler's selection of the latest version of gcc on your machine, you can use compiler option --gcc-toolchain=<path_to_base_gcc_install> to point to a previous gcc/g++ version.
Planned Future Fix
- In a future release, an additional check will be added to the icpx driver that will use better diagnostics to handle this situation. There will also be a fallback mechanism to select earlier gcc/g++ versions, if any are available.
-
APT and YUM installer packages will specify the dependency on libstdc++ so that the package manager can install the dependencies during installation.
Background
Intel® oneAPI DPC++/C++ Compiler relies on the C++ runtime (libstdc++) from the GNU g++ package on Linux.
The icpx driver can detect the GNU gcc version that is installed on your machine. If multiple versions are detected, the driver will pick the latest version installed.
The latest version of GNU gcc installed must also have the equivalent g++ package installed. If it does not, you will encounter this fatal error.
Moreover, currently the APT and YUM package installers for the Intel® oneAPI DPC++/C++ Compiler don’t explicitly call out the dependency on libgcc and libstdc++, resulting in the dependencies not being installed. If the dependencies are not installed, you will encounter this error.
Examples
The following examples show how to check the g++ and gcc versions installed on your machine when running either Ubuntu* or Red Hat* Enterprise Linux.
Ubuntu*: Check g++ version
$ dpkg --list | grep -i g++
ii g++ 4:9.3.0-1ubuntu2 amd64 GNU C++ compiler
ii g++-7 7.5.0-6ubuntu2 amd64 GNU C++ compiler
ii g++-8 8.4.0-3ubuntu2 amd64 GNU C++ compiler
ii g++-9 9.4.0-1ubuntu1~20.04.1 amd64 GNU C++ compiler
ii g++-9-multilib 9.4.0-1ubuntu1~20.04.1 amd64 GNU C++ compiler(multilib support)
ii g++-multilib 4:9.3.0-1ubuntu2 amd64 GNU C++ compiler(multilib files)
Ubuntu*: Check gcc version
$ dpkg --list | grep -i gcc
ii gcc 4:9.3.0-1ubuntu2 amd64 GNU C compiler
ii gcc-10-base:amd64 10.3.0-1ubuntu1~20.04 amd64 GCC, the GNU Compiler Collection (base package)
ii gcc-10-base:i386 10.3.0-1ubuntu1~20.04 i386 GCC, the GNU Compiler Collection (base package)
ii gcc-7 7.5.0-6ubuntu2 amd64 GNU C compiler
ii gcc-7-base:amd64 7.5.0-6ubuntu2 amd64 GCC, the GNU Compiler Collection (base package)
ii gcc-8 8.4.0-3ubuntu2 amd64 GNU C compiler
ii gcc-8-base:amd64 8.4.0-3ubuntu2 amd64 GCC, the GNU Compiler Collection (base package)
ii gcc-9 9.4.0-1ubuntu1~20.04.1 amd64 GNU C compiler
ii gcc-9-base:amd64 9.4.0-1ubuntu1~20.04.1 amd64 GCC, the GNU Compiler Collection (base package)
ii gcc-9-multilib 9.4.0-1ubuntu1~20.04.1 amd64 GNU C compiler (multilib support)
ii gcc-9-offload-nvptx 9.4.0-1ubuntu1~20.04.1 amd64 GCC offloading compiler to NVPTX
ii gcc-multilib 4:9.3.0-1ubuntu2 amd64 GNU C compiler (multilib files)
Red Hat* Enterprise Linux*: Check g++ version
$ yum list installed | grep -i gcc-c++
gcc-c++.x86_64 8.5.0-18.el8 @appstream
Red Hat* Enterprise Linux*: Check gcc version
$ yum list installed | grep -i gcc
gcc.x86_64 8.5.0-18.el8 @baseos
gcc-c++.x86_64 8.5.0-18.el8 @appstream
gcc-gdb-plugin.x86_64 8.5.0-18.el8 @appstream
gcc-gfortran.x86_64 8.5.0-18.el8 @appstream
gcc-toolset-9-elfutils.x86_64 0.176-5.el8 @AppStream
gcc-toolset-9-elfutils-devel.x86_64 0.176-5.el8 @AppStream
gcc-toolset-9-elfutils-libelf.x86_64 0.176-5.el8 @AppStream
gcc-toolset-9-elfutils-libelf-devel.x86_64 0.176-5.el8 @AppStream
gcc-toolset-9-elfutils-libs.x86_64 0.176-5.el8 @AppStream
gcc-toolset-9-runtime.x86_64 9.0-4.el8 @AppStream
libgcc.i686 8.5.0-18.el8 @baseos
libgcc.x86_64 8.5.0-18.el8 @baseos