铛似乎使用gcc库 [英] clang seems to use the gcc libraries
问题描述
这是我第一次使用 clang
。我注意到从clang引用std库的任何错误如下所示:
/ usr / bin /../ lib /gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:245:7:
^^^ ^^^ ^^^
所以它看起来像是clang链接 - 或者至少包括 - gcc库。
我使用的命令: clang ++ -c -Wall -Wextra -Werror -g test.cpp -o test.o
。 (该程序有一个故意的错误只是为了证明这一点)。
这怎么可能?我可以做些什么来使 clang
使用它自己的库(但不能打破gcc)?
其他信息:
我在Ubuntu 14.04机器上。
clang ++ --version
Ubuntu clang版本3.5-1ubuntu1(trunk)(基于LLVM 3.5)
目标:x86_64-pc-linux-gnu
线程模型: posix
g ++ --version
g ++(Ubuntu 4.8.2-19ubuntu1)4.8.2
版权所有(C)2013 Free Software Foundation,Inc.
我以前安装过几个版本(同时,它们用于 update-alternatives $
gcc
加上 apt-get
。现在我只有 4.8
(我已经卸载了其他)。那我可以搞砸了吗?我从来没有安装过clang(我猜这是默认的Ubuntu)。
澄清:正确的程序编译并运行在 clang ++
进一步的测试:我知道 gcc
没有实现像 is_trivially_constructible
并在
一个非常基本的程序
#include< iostream>
使用namespace std;
int main(){
cout<< Yada Yada<< ENDL;
返回0;
}
在编译时使用-std = c ++ 1y时出现此错误++:
从/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/包含的文件中。 /../../../include/c++/4.8/iostream:39:
...
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8 /../../../../include/c++/4.8/cstdio:120:11:错误:全局命名空间中没有名为'gets'的成员使用:: gets获取;
~~ ^
所以现在我无法用 c ++ 1y
in clang。
您需要安装 libc ++
并让clang与 -stdlib = libc ++一起使用
This is the first time I use clang
. What I notices is that any error from clang referencing the std library looks like this:
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:245:7:
^^^ ^^^ ^^^
So it looks like clang links — or at least includes — the gcc libraries.
The command I used: clang++ -c -Wall -Wextra -Werror -g test.cpp -o test.o
. (The program had a intentional error just to prove this).
How is this possible? What can I do to make clang
use its own libraries (but not break gcc)?
Additional information:
I am on a Ubuntu 14.04 machine.
clang++ --version
Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
Target: x86_64-pc-linux-gnu
Thread model: posix
g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
I had previously installed several versions (at the same time, used them with update-alternatives
) of gcc
with apt-get
. Right now I have only 4.8
(I have uninstalled the others). Could I have messed up something then? I have never installed clang (I guess it is default with Ubuntu).
Just to clarify: the correct programs compile and run in clang++
.
Further tests: I know that gcc
didn’t implement yet types like is_trivially_constructible
and move operations on iostream
in their standard c++11 library (https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html) and that clang has full c++11 conforming library so I tested those compiling with clang and I got the corresponding gcc errors, which only confirms that clang is using gcc libraries.
A very basic program
#include <iostream>
using namespace std;
int main() {
cout << "Yada Yada" << endl;
return 0;
}
gives this error when compiling with -std=c++1y in clang++:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/iostream:39:
...
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/cstdio:120:11: error: no member named 'gets' in the global namespace
using ::gets;
~~^
So right now I can’t compile anything with c++1y
in clang.
You need to install libc++
and make clang use it with -stdlib=libc++
这篇关于铛似乎使用gcc库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!