I have installed Intel Parallel Studio XE v18.0.1 on my mac and was trying to run a hello_world.cpp program. But I got into the following error.
hello.cpp(1): catastrophic error: cannot open source file "iostream" #include<iostream> ^ compilation aborted hello.cpp (code 4)
Then I checked the version of icc and icpc from command line and found both of them are version 18.0.1. Any idea how to solve this issue?
Thanks in advance,
Set the environment variables before using the compiler by sourcing the shell script compilervars.sh or compilervars.csh. Depending on the shell you use, you can use either the source command or a . (dot) to source the shell script, according to the following rules:
.csh script: Use the source command.
Bash: Use either the source command or . (dot space).
Dash or other POSIX-compliant shell: Use . (dot space).
//# Bash shell: source /<install-dir>/bin/compilervars.sh <arg> . /<install-dir>/bin/compilervars.sh <arg> //# examples: (assuming <install-dir> is /installed/compiler/) prompt> source /installed/compiler/bin/compilervars.sh ia32 prompt> . /installed/compiler/bin/compilervars.sh ia32 // OR //# C shell: source /<install-dir>/bin/compilervars.csh <arg> //# example: (assuming <install-dir> is /installed/compiler/) prompt> source /installed/compiler/bin/compilervars.csh ia32 // OR //# Dash or other POSIX-compliant shell: . /<install-dir>/bin/compilervars.sh <arg> //# example: (assuming <install-dir> is /installed/compiler/) prompt> . /installed/compiler/bin/compilervars.sh ia32
The environment script file requires a target architecture argument <arg>:
The default install path is /opt/intel/bin/<version>/ if the installation was conducted by the root user, where <version> is the version of the compiler you wish to set the environment for.
If you want the script to run automatically, add the same command to the end of your startup file.
Sample .bash_profile entry for compilervars.sh for IA-32 architecture targets only:
# set environment vars for Intel® C++ Compiler source <install-dir>/bin/compilervars.sh ia32
Symbolic links are created in the /opt/intel directory at install. The environment variables use symbolic links; however, if two versions of the Intel® C++ Compiler are installed, the most recently installed version will be symbolically linked.
With some Linux* distributions, if the Intel® C++ compiler (icpc) is sourced using compilervars.sh from the .bash_profile, the location of LIBRARY_PATH may not be set as expected. It may be necessary to source compilervars.sh after starting a terminal session.
If the proper environment variables are not set, an error similar to the following will appear when attempting to execute a compiled program:
./a.out: error while loading shared libraries: libimf.so: cannot open shared object file: No such file or directory
BTW, the Intel C++ compiler requires the host (generally Gnu C++) compiler and libraries be installed and in PATH/INCLUDE/... (that is where iostream and other C/C++ headers located).