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?
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
powis not new, you can useasm (".symver pow, pow@GLIBC_2.2.5");. This will tell gcc thatpowwas available since glibc version 2.2.5, so gcc won't tell the linker that glibc 2.29 is needed.powhas 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
powfrom glibc 2.29, but that it intentional. That optimized version is missing from your RedHat 8 machine.And just to be complete: this is
powfromlibm, which is the math part ofglibc. It is notstd::pow(double, double)from C++. That tells us thatstd::pow(double, double)is a thin inline wrapper forpow, as expected.