Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship between GLIBCXX(libstdc++.so.6) and gcc version

Tags:

c++

linux

gcc

g++

[Situation]

I'm developing a c++ library. I had a issue with the GLIBCXX version.

Before, I developed on version machine GLIBCXX_3.4.22.

But my library is not working on the target machine which has GLIBCXX_3.4.19.

So, I downgraded gcc version from 5.2.x to 4.8.x and GLIBCXX version from 3.4.22 to 3.4.19.

It successfully ran on the target machine.

But my development machine(ubuntu) boot fails because other libraries can't find GLIBCXX 3.4.22 version which is already linked to that version.

So, I re-installed GLIBCXX 3.4.22 but gcc version is still 4.8.5.

[Question]

  1. Does my library compiled on gcc-4.8.5 not use GLIBCXX_3.4.22 version? Is it fine to develop on this environment (gcc 4.8.5, GLIBCXX_3.4.22)?

  2. What is the relationship between gcc(compile) version and GLIBCXX(GLIBC) version on the linux machine.

  3. Where can I check the correct version compatibility mapping information between gcc and GLIBCXX(GLIBC)?

like image 550
Yoonsung Lee Avatar asked Jan 30 '23 06:01

Yoonsung Lee


1 Answers

libstdc++ (which is where the GLIBCXX_* versioned symbols are from) has been ABI compatible from GCC 3.4.0 to now.

  1. Your library will use the latest symbol versions from libstdc++ at the time of compile. The compiler version does not matter, except

  2. GCC 5.1 added C++11 support with a "dual ABI" in libstdc++. Code compiled in C++11 mode will use symbols with the [abi:cxx11] tag, and that may not interoperate with code compiled without C++11 (whether from an older compiler without C++11 support, or a newer compiler set to use an older standard).

  3. https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

If you need to build binaries that run on older systems, I would recommend setting up an older distribution inside a container and building in there, with all old libraries. This way, nothing newer from your development system can leak into them.

like image 158
ephemient Avatar answered Feb 05 '23 15:02

ephemient