What the difference between libc++ and libstdc++? libc++ is part of clang project and libstdc++ is part of GCC project. They are compatible for C++17 and older versions, but C++20 implementation is not ready, so they have differences in implemented features, we'll have to wait until they are done. How to determine which versions of these libs support specific standard version? For example which version of c++ standard does libstdc++-4.6 support? In their documentation, for example you can check what version GCC libstdc++ supports here: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html Copy pasting libs may or may not work, depending on many things. It's best to just install standard library using package manager of your operating system. Answer from stilgarpl on reddit.com
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++
The GNU C++ Library
Short Contents Copyright (C) 2008-2026 ... with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. This is the top level of the libstdc++ documentation set. The documentation is divided into the following three sections. Manual Frequently Asked Questions ...
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++ › faq.html
Frequently Asked Questions
So any program which uses libstdc++ falls under the GPL? 2.3. How is that different from the GNU {Lesser,Library} GPL? 2.4. I see. So, what restrictions are there on programs that use the library? 3.1. How do I install libstdc++? 3.2. How does one get current libstdc++ sources?
Discussions

c++ - What is libc++ and libstdc++ - Stack Overflow
I have a few questions: What is libc++ and libstdc++? What is the difference between them? Are they interchangeable? Is it something a compiler should implement? When should I use one or another? More on stackoverflow.com
🌐 stackoverflow.com
c++ - How do you find what version of libstdc++ library is installed on your linux machine? - Stack Overflow
I found the following command: strings /usr/lib/libstdc++.so.6 | grep GLIBC from here. It seems to work but this is an ad-hoc/heuristic method. Is there a specific command that can be used to quer... More on stackoverflow.com
🌐 stackoverflow.com
libstdc++ vs libstdc++11 when using gcc version 8+ and -std=c++17

What is libstdc++11?

More on reddit.com
🌐 r/cpp
21
14
July 14, 2020
gcc - What is libstdc++.so.6 and GLIBCXX_3.4.20? - Unix & Linux Stack Exchange
I am looking for some simple answers in order to understand some of these concepts. I am trying to install a R library which is failing with the error: /lib64/libstdc++.so.6: version ``GLIBCXX_3.4... More on unix.stackexchange.com
🌐 unix.stackexchange.com
🌐
Reddit
reddit.com › r/cpp_questions › some questions about libc, libc++, libstdc++
r/cpp_questions on Reddit: Some questions about libc, libc++, libstdc++
September 18, 2020 -

Can someone elaborate on what are libc, libc++, libstdc++

  1. What the difference between libc++ and libstdc++? Why can't we just use one of them for all times?

  2. How to determine which versions of these libs support specific standard version? For example which version of c++ standard does libstdc++-4.6 support?

  3. Can i just "copy-paste" these libs into target OS to run my project if that OS lacks newer versions of these ones available in repositories?

    1. Can i just "copy-paste" all dependent `.so` files into target OS? What should i consider when "copy-pasting" libraries from my development workstation to user's one?

Top answer
1 of 2
4
What the difference between libc++ and libstdc++? libc++ is part of clang project and libstdc++ is part of GCC project. They are compatible for C++17 and older versions, but C++20 implementation is not ready, so they have differences in implemented features, we'll have to wait until they are done. How to determine which versions of these libs support specific standard version? For example which version of c++ standard does libstdc++-4.6 support? In their documentation, for example you can check what version GCC libstdc++ supports here: https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html Copy pasting libs may or may not work, depending on many things. It's best to just install standard library using package manager of your operating system.
2 of 2
1
(mine) 0. What are libc++ and libstdc++ They are compiler-specific implementations of the C++ standard library. libc++ is bundled with Clang and libstdc++ with GCC. On many unix platforms Clang works with libstdc++ by default for better ABI compatibility. 1. What the difference between libc++ and libstdc++? Why can't we just use one of them for all times? They are different implementations of the same library. Your code should not really care which one it is using, unless you also want to use compiler-specific extensions. 2. How to determine which versions of these libs support specific standard version? Not sure. Look into GCC and Clang documentation. 3. Can i just "copy-paste" these libs into target OS to run my project if that OS lacks newer versions of these ones available in repositories? Can i just "copy-paste" all dependent .so files into target OS? What should i consider when "copy-pasting" libraries from my development workstation to user's one? Generally, yes but you need to take care of few things: Your executable must be able to locate the library object. This might require to edit LD_LIBRARY_PATH or inject rpath information into the executable. Licensing concerns (???) - IIRC even majority of commercial uses are fine though It's possible to use static version of the standard library - then it's inside the executable. Whatever linking you are using, the target OS must support all dependencies of the standard library implementation. This will usually be dependent on supported syscalls which are the border between user-space and kerner-space.
🌐
MIT
web.mit.edu › darwin › src › modules › gcc3 › libstdc++-v3 › docs › html › install.html
libstdc++-v3 Installation Instructions
If you're building GCC from scratch, you can do the usual 'make bootstrap' here, and libstdc++-v3 will be built as its default C++ library. The generated g++ will magically use the correct headers, link against the correct library binary, and in general using libstdc++-v3 will be a piece of cake.
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++ › latest-doxygen › index.html
libstdc++ Source Documentation
August 23, 2024 - There are two types of documentation for libstdc++. One is the distribution documentation, which can be read online here or offline from the file doc/html/index.html in the library source directory.
🌐
Linux From Scratch
linuxfromscratch.org › lfs › view › development › chapter05 › gcc-libstdc++.html
5.6. Libstdc++ from GCC-16.1.0
This specifies the installation directory for include files. Because Libstdc++ is the standard C++ library for LFS, this directory should match the location where the C++ compiler ($LFS_TGT-g++) would search for the standard C++ include files. In a normal build, this information is automatically ...
🌐
Llvm
libcxx.llvm.org
“libc++” C++ Standard Library — libc++ documentation
Our experience (and the experience of libstdc++ developers) is that adding support for C++11 (in particular rvalue references and move-only types) requires changes to almost every class and function, essentially amounting to a rewrite. Faced with a rewrite, we decided to start from scratch ...
Find elsewhere
Top answer
1 of 4
124

To find which library is being used you could run

Copy $ /sbin/ldconfig -p | grep stdc++
    libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6

The list of compatible versions for libstdc++ version 3.4.0 and above is provided by

Copy $ strings /usr/lib/libstdc++.so.6 | grep LIBCXX
 GLIBCXX_3.4
 GLIBCXX_3.4.1
 GLIBCXX_3.4.2
 ...

For earlier versions the symbol GLIBCPP is defined.

The date stamp of the library is defined in a macro __GLIBCXX__ or __GLIBCPP__ depending on the version:

Copy// libdatestamp.cxx
#include <cstdio>

int main(int argc, char* argv[]){
#ifdef __GLIBCPP__
    std::printf("GLIBCPP: %d\n",__GLIBCPP__);
#endif
#ifdef __GLIBCXX__
    std::printf("GLIBCXX: %d\n",__GLIBCXX__);
#endif
   return 0;
}

$ g++ libdatestamp.cxx -o libdatestamp
$ ./libdatestamp
GLIBCXX: 20101208

The table of datestamps of libstdc++ versions is listed in the documentation:

2 of 4
22

What exactly do you want to know?

The shared library soname? That's part of the filename, libstdc++.so.6, or shown by readelf -d /usr/lib64/libstdc++.so.6 | grep soname.

The minor revision number? You should be able to get that by simply checking what the symlink points to:

Copy$ ls -l  /usr/lib/libstdc++.so.6
lrwxrwxrwx. 1 root root 19 Mar 23 09:43 /usr/lib/libstdc++.so.6 -> libstdc++.so.6.0.16

That tells you it's 6.0.16, which is the 16th revision of the libstdc++.so.6 version, which corresponds to the GLIBCXX_3.4.16 symbol versions.

Or do you mean the release it comes from? It's part of GCC so it's the same version as GCC, so unless you've screwed up your system by installing unmatched versions of g++ and libstdc++.so you can get that from:

Copy$ g++ -dumpversion
4.6.3

Or, on most distros, you can just ask the package manager. On my Fedora host that's

Copy$ rpm -q libstdc++
libstdc++-4.6.3-2.fc16.x86_64
libstdc++-4.6.3-2.fc16.i686

As other answers have said, you can map releases to library versions by checking the ABI docs

🌐
Debian
packages.debian.org › sid › libstdc++6
Debian -- Details of package libstdc++6 in sid
libstdc++-v3 is a complete rewrite from the previous libstdc++-v2, which was included up to g++-2.95.
🌐
Reddit
reddit.com › r/cpp › libstdc++ vs libstdc++11 when using gcc version 8+ and -std=c++17
r/cpp on Reddit: libstdc++ vs libstdc++11 when using gcc version 8+ and -std=c++17
July 14, 2020 -

Is there a difference between libstdc++ and libstdc++11 in the current releases of gcc (or at least gcc >=8)?

I want to create libraries that support code using the C++17 standard.

I can't find any concise answer on which lib to use or if it even matters.

🌐
Brown University
cs.brown.edu › people › jwicks › libstdc++ › html › 17_intro › howto.html
libstdc++-v3 HOWTO: Chapter 17: Library Introduction
The libstdc++-v3 library (unlike libstdc++-v2, all of it, not just the STL) has been designed so that multithreaded applications using it may be written. The first problem is finding a fast method of implementation portable to all platforms. Due to historical reasons, some of the library is written against per-CPU-architecture spinlocks and other parts against the gthr.h abstraction layer which is provided by gcc.
🌐
Linux From Scratch
linuxfromscratch.org › lfs › view › 12.1-systemd › chapter05 › gcc-libstdc++.html
5.6. Libstdc++ from GCC-13.2.0
This specifies the installation directory for include files. Because Libstdc++ is the standard C++ library for LFS, this directory should match the location where the C++ compiler ($LFS_TGT-g++) would search for the standard C++ include files. In a normal build, this information is automatically ...
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++ › manual › using.html
Chapter 3. Using - GCC, the GNU Compiler Collection
The set of features available in the GNU C++ library is shaped by several GCC Command Options. Options that impact libstdc++ are enumerated and detailed in the table below.
🌐
Debian
packages.debian.org › bullseye › libstdc++6
Debian -- Details of package libstdc++6 in bullseye
libstdc++-v3 is a complete rewrite from the previous libstdc++-v2, which was included up to g++-2.95.