Skip to content
Advertisement

Fedora 28 / GLIBC 2.27 libm.so.6 logf() and powf() c++

As I am sure other Fedora 28 users will know, the OS’s glibc was recently updated to glibc 2.27. Amongst many other things, 2.27 has added new implementations of logf() and powf(). This has caused my application to fail to run on distributions with an older glibc (Debian, for example). When the application is invoked on Debian, the following error is produced:

  • … libm.so.6 version GLIBC-2.27 not found (required by ./app_name)

I tracked the symbols down to logf and powf by using the following procedure:

JavaScript

Which gave the following output:

JavaScript

And then…

JavaScript

Which gave the following output:

JavaScript

and…

JavaScript

So, armed with the information that powf() and logf() are also implemented in GLIBC-2.0, I added the following to my project (above main()) and recompiled.

JavaScript

Unfortunately, my project is still using powf and logf from GLIBC-2.27. It’s actually quite important that I distributed binaries for Debian and I would prefer not to have to compile on that distribution if I can avoid it.

Historically, I have successfully used this procedure for symbols in libc.so.6 but not libm.so.6. Should I be doing things differently for libm.so.6?

Clearly, I am missing something here so I would be grateful for any help offered.

Many thanks

Amanda

Advertisement

Answer

I think the problem is that you used objdump to find the symbol versions of the 32-bit libm, and I assume you’re actually building a 64-bit application. In a Fedora 28 container if I look at the 64-bit library then I see these versions instead:

JavaScript

And this works as expected:

JavaScript

It uses the versions from the 64-bit library:

JavaScript

So I think the problem was that you were trying to link to symbols that simply aren’t in the 64-bit library (because glibc didn’t have 64-bit versions of those symbols until version 2.2.5, so they don’t exist with the GLIBC_2.0 version).

To make it work for 32-bit or 64-bit you could do:

JavaScript

That uses the right version for the wordsize:

JavaScript
Advertisement