9

I have a couple of questions.

1) What is libc++ and libstdc++ ?

2) What is the difference between them ?

3) Are they interchangeable ?

4) Is it something a compiler should implement ?

5) When should I use one or another ?

  • 2
    Related: http://stackoverflow.com/questions/14972425/should-i-use-libc-or-libstdc?rq=1 – Thilo Nov 18 '16 at 11:42

2 Answers2

8

1) What is libc++ and libstdc++ ?

They are implementations of the C++ standard library.

2) What is the difference between them ?

They are entirely different implementations.

3) Are they interchangeable ?

Yes, you should be able to use them interchangeably. (However you can't easily use both in the same program.)

5) When should I use one or another ?

You shouldn't have to worry about that. Your code should work with any standard library implementation.

EricWF
  • 1,005
  • 7
  • 8
  • 1
    While point 5 is theoretically true, I've encountered several instances where one is buggy so you have to use the other. For instance, regex's with libc on Ubuntu 14.04. – Matt Mar 12 '18 at 15:52
  • Saying entire different in this case, for differences doesn't help a bit :) – AdityaG15 Sep 17 '22 at 15:25
6

libstdc++ is the GNU c++ standard library implementation.

libc++ is the LLVM/clang c++ standard library implementation.

Even when compiling with clang, libstdc++ is often used (on Linux).

A main reason libc++ exists is that libstdc++ is GPL and so Apple can't ship it, so you can think of libc++ as the non-GPL libstdc++.

Tom Huntington
  • 2,260
  • 10
  • 20