5

[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)?

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
Yoonsung Lee
  • 115
  • 1
  • 9

1 Answers1

10

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.

ephemient
  • 198,619
  • 38
  • 280
  • 391
  • Thank for your help. I miss-understood about gcc compilation. I have to downgrade gcc and glibc version both. – Yoonsung Lee Nov 07 '17 at 07:17
  • @YoonsungLee: You can install multiple gcc versions in parallel, so there is no need to downgrade your system libs. You can compile also against a "virtual" system. gcc looks into that given system dirs to find correct libs. – Klaus Nov 07 '17 at 07:19
  • @Klaus I can change gcc dynamically. But, do the gcc reference the GLIBC library on current libversion when compile ? For example, when I build the gcc version 4.8 with system glibcxx3.4.22, the result birnary cannot run on the system lib version glibcxx3.4.19. Is it right? I have a problem to do not change system lib dynamically on development environment because system lib is referenced by other programs. – Yoonsung Lee Dec 20 '17 at 08:47
  • @YoonsungLee: You can force your runtime linker to use specific versions. https://stackoverflow.com/questions/13367025/how-to-force-using-local-shared-libraries-over-system-libraries – Klaus Dec 20 '17 at 08:53
  • @Klaus : What you mean is to link to process ? or link to library file? If you mean to link to process when startup, I can't because original process is jvm and the library file is dynamically loaded. – Yoonsung Lee Dec 27 '17 at 05:21