Read through markdown version: https://github.com/shannon112/cpp-is-a-good-person/blob/main/Concept/compiler_and_stdlib.md
org | compiler | official site |
---|---|---|
LLVM | clang / clang++ | https://clang.llvm.org/ |
GNC | gcc / g++ | https://gcc.gnu.org/. |
org | library | file | official site |
---|---|---|---|
LLVM | "libc++” C++ Standard Library (clang++ stdlib default) | libc++.so and libc++abi.so | https://libcxx.llvm.org/ |
GNC | The GNU C++ Library (g++ stdlib default) | libstdc++ | https://gcc.gnu.org/onlinedocs/libstdc++/ |
GNC | The GNU C Library (glibc) | libc.so | https://www.gnu.org/software/libc/ |
GNC | The GCC low-level runtime library | libgcc.a or libgcc_s.so | https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html |
LLVM
- The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and converts it into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer. It also contains basic regression tests. https://llvm.org/docs/GettingStarted.html
- C-like languages use the Clang front end. This component compiles C, C++, Objective C, and Objective C++ code into LLVM bitcode – and from there into object files, using LLVM.
- Other components include: the libc++ C++ standard library, the LLD linker, and more.
GCC (GNU)
- The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages (libstdc++,...). GCC was originally written as the compiler for the GNU operating system. The GNU system was developed to be 100% free software, free in the sense that it respects the user's freedom. https://gcc.gnu.org/
Discussion about cross using
- https://stackoverflow.com/questions/19774778/when-is-it-necessary-to-use-the-flag-stdlib-libstdc
- g++ with libstdc++ (by default)
g++ test.cpp -std=c++17
- g++ with libc++
g++ -nostdinc++ -I<libcxx-install-prefix>/include/c++/v1 \ test.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc
- clang++ with libc++ (by default)
clang++ test.cpp -std=c++17 clang++ test.cpp -stdlib=libc++
- clang++ with libstdc++
clang++ test.cpp -stdlib=libstdc++
Discussion about gcc v.s. g++
Check
- Print the lists of directories and candidate libraries stored in the current cache https://linux.die.net/man/8/ldconfig
ldconfig -p | grep <library>`
- Display information about ELF files (find the shared libraries that are needed to the executable file) https://man7.org/linux/man-pages/man1/readelf.1.html
readelf -d <executable_file>
- Check version
gcc --version g++ --version clang --version clang++ --version
- Check location
which gcc which g++ which clang which clang++
0 comments:
張貼留言
留言