Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Md_Fazlay_R_
Beginner
222 Views

catastrophic error: cannot open source file "iostream"

Hello All,

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,

Fazlay

0 Kudos
5 Replies
MGRAV
Novice
222 Views

Have you Xcode or the command line tools installed ?

Md_Fazlay_R_
Beginner
222 Views

Hi,
I have installed command line tools.

Thanks,

Fazlay

jimdempseyatthecove
Black Belt
222 Views

Linux* and OS X*:

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.

  • .sh script:

    • 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>:

  • ia32: Compiler and libraries for IA-32 architecture-based targets only.
  • intel64: Compiler and libraries for Intel® 64 architecture-based targets only.

 

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

Note

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.

Note

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


Jim Dempsey

jimdempseyatthecove
Black Belt
222 Views

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).

Jim Dempsey

Md_Fazlay_R_
Beginner
222 Views

Thanks so much Jim! Its working now :)