skip to Main Content

I’m building on Ubuntu 20.04 and my program executed on RedHat 8 just fine until I included <cmath> and used std::pow(double, double). Now I get the following error on RedHat 8:

/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /MyOwnLib.so)

What is so special about std::pow that it requires GLIBC 2.29? This function is very old. Can I somehow force the compiler on Ubuntu to "link" an older version?

3

Answers


  1. Chosen as BEST ANSWER

    A colleague of mine pointed out that I can use std::powf instead which is available in GLIBC 2.28 and does not require GLIBC 2.29. Not really a solution, but my solution, so I will mark it as accepted answer.

    For somebody who can't do that look at the comment of @pptaszni to my original question: probably use an older Linux to compile on.


  2. C++ is not ABI stable: when you build something on your machine it will work on your machine only. This is because the binary produced is specific to your architecture.

    In this case it seems that there is a mismatch of the C standard library (libc).

    If you want to don’t depend from the system implementation of the standard C++ you can try to statically link to the standard library.

    If you use gcc or clang try -static compiler option.

    The solution to your problem would be compile your program to the target platform.

    Login or Signup to reply.
  3. There’s nothing special. There’s surprising little coordination between gcc, glibc and the linker people, despite them all being "GNU". To tell gcc that pow is not new, you can use asm (".symver pow, pow@GLIBC_2.2.5");. This will tell gcc that pow was available since glibc version 2.2.5, so gcc won’t tell the linker that glibc 2.29 is needed. pow has been around for way longer of course, but 2.2.5 introduced this versioning scheme.

    The downside is that you miss out on the optimized version of pow from glibc 2.29, but that it intentional. That optimized version is missing from your RedHat 8 machine.

    And just to be complete: this is pow from libm, which is the math part of glibc. It is not std::pow(double, double) from C++. That tells us that std::pow(double, double) is a thin inline wrapper for pow, as expected.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search