gpt4 book ai didi

c++ - 为什么 clang++ 链接到 gcc?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:34:49 25 4
gpt4 key购买 nike

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

#include <cstdlib>
#include <iostream>

using namespace std;

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

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

$ 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?

谢谢

最佳答案

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

关于c++ - 为什么 clang++ 链接到 gcc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39968343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com