首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么clang++链接到gcc?

为什么clang++链接到gcc?
EN

Stack Overflow用户
提问于 2016-10-10 23:35:27
回答 1查看 944关注 0票数 5

我有一个简单的"Hello,world“风格的程序,我正在用clang++在FreeBSD上编译:

代码语言:javascript
复制
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
    cout << "Oh, hello" << endl;
    return EXIT_SUCCESS;
}

我用clang++和它的libc++编译它:

代码语言:javascript
复制
$ clang++ -stdlib=libc++ -v ohhello.cpp 
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/clang++" -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name ohhello.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.8.0 -internal-isystem /usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /usr/home/mike/projects/ohhello -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/ohhello-050a75.o -x c++ ohhello.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target x86_64-unknown-freebsd11.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/v1
 /usr/bin/../lib/clang/3.8.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/ohhello-050a75.o -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

在链接器步骤中,我多次看到"-lgcc“和"-lgcc_s”。如果clang++使用的是libc++ (而不是libstdc++),它为什么要与gcc联系呢?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-10 23:40:56

libgcc不是gcc。这是一个小的,non compiler-specific C library。它是gcc提供的,但并不是编译器特有的。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39968343

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档