Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is libc++ and libstdc++

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 ?

like image 621
Виталик Бушаев Avatar asked Nov 18 '16 11:11

Виталик Бушаев


People also ask

What is the purpose of libc?

The term "libc" is commonly used as a shorthand for the "standard C library", a library of standard functions that can be used by all C programs (and sometimes by programs in other languages). Because of some history (see below), use of the term "libc" to refer to the standard C library is somewhat ambiguous on Linux.

Is libc and glibc the same?

libc6 and glibc are the same version of libc; officially, it's version 2 of the GNU C Library (but it's the sixth major version of the Linux C library). You can read more about glibc at the GNU C Library pages.

Does C++ use libc?

Most implementations of libstdc++ depend on libc, so they require it. The C++ standard includes most of the C standard library. So it's kind of a dependency and technically it's part of the C++ standard library.

What is libc ++ abi?

libc++abi is a new implementation of low level support for a standard C++ library. All of the code in libc++abi is dual licensed under the MIT license and the UIUC License (a BSD-like license).


2 Answers

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.

like image 94
EricWF Avatar answered Oct 06 '22 01:10

EricWF


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++.

like image 25
Tom Huntington Avatar answered Oct 05 '22 23:10

Tom Huntington