Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

catastrophic error: cannot open source file "iostream"

Md_Fazlay_R_
Beginner
1,839 Views

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
New Contributor I
1,839 Views

Have you Xcode or the command line tools installed ?

0 Kudos
Md_Fazlay_R_
Beginner
1,839 Views

Hi,
I have installed command line tools.

Thanks,

Fazlay

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,839 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

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,839 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

0 Kudos
Md_Fazlay_R_
Beginner
1,839 Views

Thanks so much Jim! Its working now :)

0 Kudos
Reply