I've tried to compile simple hello world on Fedora 20 with Clang, and I get the following output:
d.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
I don't have any idea how to resolve it.
I've tried to compile simple hello world on Fedora 20 with Clang, and I get the following output:
d.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
I don't have any idea how to resolve it.
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.
This is because g++ is not installed, so libstdc++ is not present.
You can install g++, or if LLVM is preferred, install LLVM libc++ and specify that you want to use it, like so:
sudo apt-get install libc++-dev
clang++ -stdlib=libc++ <rest of arguments>
You may wish to link /usr/bin/c++ to the default compiler:
ln -s /usr/bin/c++ /usr/bin/clang++-libc++
and then compile simply using
$ c++ <args_as_usual>
I ran into this problem because I had a filename.c
where I needed a filename.cpp
. Obviously the compiler isn't going to be able to find C++ headers when I tell it I'm writing C!