c++ - Clang 看不到基本标题

标签 c++ c++11 clang clang++ llvm-clang

我尝试在 Fedora 20 上使用 Clang 编译简单的 hello world,我得到以下输出:

d.cpp:1:10: fatal error: 'iostream' file not found

#include <iostream>

我不知道如何解决它。

最佳答案

这是因为 g++ 没有安装,所以 libstdc++ 不存在。

您可以安装 g++,或者如果首选 LLVM,请安装 LLVM libc++ 并指定要使用它,如下所示:

sudo apt-get install libc++-dev
clang++ -stdlib=libc++ <rest of arguments>

您可能希望将/usr/bin/c++ 链接到默认编译器:

ln -s /usr/bin/c++ /usr/bin/clang++-libc++

然后简单地使用

编译
$ c++ <args_as_usual>

关于c++ - Clang 看不到基本标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26333823/

相关文章:

c++ - C++中关联packaged_task和thread

c++ - 使用 C++ lambda 表达式初始化类成员

c++ - Clang:x86 FPU 调用约定

c++ - x86-64 movl 和 cmpl 区别

c++ - golang gcc c++ 现有的静态库在制作PIE对象时不能使用;使用 -fPIC 重新编译

c++ - C++ 中的意外循环行为

clang - .clang-tidy 配置文件内容被忽略

macos - 如何在我的新 MacBook Pro(使用 Mac OS Catalina)上安装 openMP?

c++ - ./libmylib.so : undefined reference to `submarinex::LIB::kCount'

c++ - 在 C++11 中声明接口(interface)的最佳方法