Locating iostream in Clang++: fatal error: 'iostream' file not found
I have also been troubled by this problem for a long time.You should try to delete the folder(cd /usr/lib/gcc/aarch64-linux-gnu/8). The reason why clang++ can't work is this folder doesn't contain libstdc++.a.
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/7.3.0
Selected GCC installation: /usr/bin/../lib/gcc/aarch64-linux-gnu/7.3.0
check all the folders in /usr/lib/gcc/aarch64-linux-gnu/
clang++ will choose the last one,make sure there is the libstdc++.a in the last one
Clang doesn't see basic headers
Point 3 solved the problem for me.
1.
Had the same issue, fedora 21::clang 3.5.0:
clang++ -std=c++14 -pedantic -Wall test_01.cpp -o test_01 -v
2.
ignoring nonexistent directory "/usr/lib/gcc/i686-redhat-linux/4.9.2/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/bin/../lib/clang/3.5.0/include
/usr/include
End of search list.
test_01.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
3.
sudo yum install gcc-c++
4.
#include "..." search starts here:
#include <...> search starts here:
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/i686-redhat-linux
/bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/backward
/usr/local/include
/usr/bin/../lib/clang/3.5.0/include
/usr/include
/usr/lib/gcc/i686-redhat-linux/4.9.2/include
End of search list.
Fatal error: iostream: No such file or directory in compiling C program using GCC
Neither <iostream>
nor <iostream.h>
are standard C header files. Your code is meant to be C++, where <iostream>
is a valid header. Use a C++ compiler such as clang++
or g++
(and a .cpp
file extension) for C++ code.
Alternatively, this program uses mostly constructs that are available in C anyway. It's easy enough to convert the entire program to compile using a C compiler. Simply remove #include <iostream>
and using namespace std;
, and replace cout << endl;
with putchar('\n');
... I advise compiling using C99, C11 or C18 (eg. gcc -std=c99
, clang -std=c18
etc)
Related Topics
How to Prevent Screen-Savers and Sleeps During My Program Execution
How to Get Size of Check and Gap in Check Box
How to Traverse a Boost::Multi_Array
Using Memory Sanitizer with Libstdc++
How to Sort C++ Array in Asc and Desc Mode
How to Add Code at the Entry of Every Function
In C++, Is a Function Automatically Virtual If It Overrides a Virtual Function
What's the Difference Between C and C++
After Sending a Lot, My Send() Call Causes My Program to Stall Completely. How Is This Possible
How to Implement a Video Widget in Qt That Builds Upon Gstreamer
How Visitor Pattern Avoid Downcasting
Calculate Md5 of a String in C++
Is Rdtsc Timer Inaccurate in Linux
Is Gcc Considering Builtins of Non-Constant Expression Functions to Be Constant Expressions
Constructor as a Function Try Block - Exception Aborts Program
Array[Byte] to Hbitmap or Cbitmap