libmath-finite intends to solve the __xxx_finite
symbols missed problem due to glibc
upgrade. It generally happens when distribute your pre-built binray(.a/.so/executable
) from glibc<2.31
build enviornment to glibc>=2.31
systems, such as Debian 10 -> Debian 11
, or Ubuntu18.04 -> Ubuntu20.04
. Math changes in glibc 2.31 also discusses the problem.
It's a very simple library, which only wraps functions of the standard math library libm
. Many thanks to Étienne who proposes the idea in Link errors with -ffast-math (-ffinite-math-only) and glibc 2.31.
Please read Undefined reference to __xxx_finite
- why and how?.
There're various ways to use it. The simplest way is just copy the sources into your project and compile them together. Alternativesly build static/shared library to and link them. Read Undefined reference to __xxx_finite
- why and how? for more details.
- Build static library
$ gcc -c -o libmath-finite.o libmath-finite.c
$ ar rcs libmath-finite.a libmath-finite.o
- Build shared library
$ gcc -c -fPIC -o libmath-finite.o libmath-finite.c
$ gcc -shared -fPIC -o libmath-finite.so libmath-finite.o -lm
- Math changes in glibc 2.31
- Math changes in glibc 2.31 - Answer page
- Proposal: Remove or reduce math-finite.h
- Link errors with -ffast-math (-ffinite-math-only) and glibc 2.31
- sourceware.org - glibc.git
- sourceware.org - glibc.git - commit: remove math-finite.h redirections for math functions
- C - Common mathematical functions
- GCC - FloatingPointMath Optimiation
- GCC - Options That Control Optimization
- How the GNU C Library handles backward compatibility
- Undefined reference to
__xxx_finite
- why and how? - Undefined reference to
__xxx_finite
- why and how? - medium.com - Undefined reference to
__xxx_finite
- why and how? - github.io