Written and maintained by CASRAI Editorial Board
Last updated
FLINT (Fast Library for Number Theory) is a free C library for fast arithmetic in number theory and computer algebra. It is unrelated to any public library in Flint, Michigan. This guide is for researchers who need to install FLINT, either directly or through its Python binding, and run a first computation they can check by hand.
Short answer: install the Python binding with pip install python-flint for scripting, or build the C library from a release tarball with ./configure, make and make install for C or C++ work. Both routes are described below with the commands given in the official documentation.
What FLINT is used for in research
According to the project site (flintlib.org, read 2026-11-08), FLINT supports arithmetic with integers, rationals, algebraic, real, complex and p-adic numbers, finite fields and number fields, plus univariate and multivariate polynomials, power series and matrices. Listed features include primality testing, integer and polynomial factorisation, multivariate polynomial GCD, fast Fourier transforms, LLL lattice reduction, and ball arithmetic with rigorous error bounds (merged into FLINT 3.0 from the earlier Arb, Antic and Calcium projects). It is licensed LGPL v3 or later, has a C API in the style of GMP, and runs on Linux, macOS and Windows.
The same site states that FLINT is a back-end for SageMath, OSCAR, Singular, Macaulay2, Maple and Mathematica. In practice that means many researchers use FLINT without installing it separately. See the SageMath guide for that route. The subject area is covered in What Is Mathematics? and classified in the Mathematics Subject Classification.
Which route should you pick?
| Route | Install command or source | Use when |
|---|---|---|
| python-flint | pip install python-flint or conda install -c conda-forge python-flint |
You script in Python; the documentation describes it as a Python extension module wrapping FLINT and Arb. |
| C library | Release tarball: ./configure, make, make install |
You write C or C++ and link with -lflint. |
| Other bindings | Nemo.jl (Julia), Flint2 (Haskell), flintxx (C++), per flintlib.org | You work in one of those languages. |
| Inside a computer algebra system | SageMath, OSCAR, Singular and others | You already use one of those systems, which use FLINT internally. |
Install or access (official sources)
Python: python-flint
The python-flint installation page (read 2026-11-08) gives two commands: pip install python-flint and conda install -c conda-forge python-flint. It lists binaries for CPython 3.10 to 3.14 and PyPy 3.11 on Windows x86_64, macOS (Intel and ARM) and Linux x86_64 (manylinux), and a WebAssembly build through Pyodide. PyPI has no binaries for Linux aarch64 or musllinux; conda-forge provides aarch64. To test the installation run:
python -m flint.test
A working installation prints “OK: Your installation of python-flint seems to be working just fine!”
C library: build from a release tarball
The FLINT building guide (read 2026-11-08) lists these dependencies: GMP 6.2.1 or newer, MPFR 4.1.0 or newer, and GNU Make. On Debian or Ubuntu:
apt install libgmp-dev libmpfr-dev make
From an unpacked release tarball:
./configure
make -j N
make -j N check
make install
Replace N with the number of parallel jobs. The default install prefix is /usr/local. If you build from a Git checkout instead of a tarball, run ./bootstrap.sh first (it needs autoconf, libtool-bin and m4). On Windows the guide uses CMake: mkdir build && cd build, then cmake .. -DBUILD_SHARED_LIBS=ON, then cmake --build . --target install.
Documented configure options include --prefix=DIR, --with-gmp=DIR, --with-mpfr=DIR, --enable-static, --disable-shared, --enable-avx2 and --with-blas. To test a single module, use make check MOD=fmpz_poly.
Step-by-step: a first computation
In C
- Include the headers
flint/flint.h,flint/fmpz.handflint/fmpz_factor.h(the tutorial’s first program uses these three). - Declare the integer type with
fmpz_tand initialise it withfmpz_init. Factorisation data usesfmpz_factor_twithfmpz_factor_init. - Compute 30! with
fmpz_fac_ui(a, 30)and print it withflint_printf("30! = %{fmpz}.
", a) - Build 2^60 − 1 with
fmpz_one,fmpz_mul_2exp(b, b, 60)andfmpz_sub_ui(b, b, 1); take the GCD withfmpz_gcd(g, a, b); factor withfmpz_factor(fac, b)andfmpz_factor_print(fac). - Release every object with the matching clear calls, then compile:
gcc tutorial_first_fmpz.c -o first -lflint
If FLINT is installed outside the default prefix, add -I<prefix>/include -L<prefix>/lib and, to run the program, -Wl,-rpath,<prefix>/lib. pkg-config --cflags --libs flint supplies the flags where pkg-config is set up.
In Python
The python-flint reference documentation gives these checked examples for the fmpz type, after from flint import fmpz:
fmpz(30).gcd(45) # 15
fmpz.fac_ui(10) # 3628800
fmpz(5040).factor() # [(2, 4), (3, 2), (5, 1), (7, 1)]
fmpz(60).euler_phi() # 16
fmpz(60).divisor_sigma(1) # 168
The factorisation of 5040 reads 2^4 × 3^2 × 5 × 7. The documentation warns that factoring large integers can be slow unless all prime factors are small, and factor(trial_limit=...) returns an incomplete factorisation in which the largest factor may be composite.
Output and how to read it
The tutorial’s first C program prints the following (flintlib.org tutorial, read 2026-11-08):
30! = 265252859812191058636308480000000
30! has 108 bits
gcd(30!, 2^60 - 1) = 225225
2^60 - 1 = 3^2 * 5^2 * 7 * 11 * 13 * 31 * 41 * 61 * 151 * 331 * 1321
2^64 + 1 = 274177 * 67280421310721
In the factorisation lines, p^e means the prime p raised to the power e, so 3^2 * 5^2 * 7 is 3² × 5² × 7. In Python, factor() returns the same information as a list of (prime, exponent) pairs.
The second tutorial program works with fmpz_poly: it divides x^12 − 1 by (x + 1)^3, giving remainder 66x² + 120x + 54, a GCD of x + 1, a value of 999999999999 at x = 10, and six irreducible factors: x − 1, x² + x + 1, x + 1, x² − x + 1, x² + 1 and x^4 − x² + 1. Matching these values against your own build is a quick correctness check.
Troubleshooting
- Build fails with missing
gmp.hormpfr.h. Install the development packages (libgmp-dev libmpfr-devon Debian or Ubuntu), or pointconfigureat them with--with-gmp=DIRand--with-mpfr=DIR. - Program compiles but cannot find
libflintat run time. You installed to a non-default prefix. Add-Wl,-rpath,<prefix>/libwhen linking, as in the official tutorial. - Static linking errors. The building guide says a static link also needs
-lmpfr -lgmp -lpthread -lmin addition to-lflint. pip install python-flinttries to build from source. No PyPI binary exists for your platform (for example Linux aarch64 or musllinux). The installation page lists conda-forge as the route for aarch64.- Verifying a Python install. Run
python -m flint.test. - Git checkout has no
configure. Run./bootstrap.shfirst.
Other ways to reach FLINT’s functions
| Option | What it is, per its source |
|---|---|
| SageMath | A system that uses FLINT as one of its back-ends (flintlib.org); see the SageMath guide on this site. |
| Nemo.jl | Julia binding listed on flintlib.org. |
| Flint2 | Haskell binding listed on flintlib.org. |
| flintxx | C++ binding listed on flintlib.org. |
Licence and reproducibility
FLINT is open-source software under the LGPL (v3 or later); see open source licences for how such licences are read. When you publish results computed with it, record the FLINT or python-flint version and build options as part of computational reproducibility.
FAQ
What is the FLINT library?
FLINT, the Fast Library for Number Theory, is a C library for arithmetic in number theory, distributed under LGPL v3 or later (flintlib.org).
Is FLINT free?
Yes. The project site lists the licence as LGPL v3 or later.
How do I use FLINT from Python?
Install python-flint with pip install python-flint or conda-forge, then import types such as fmpz from flint.
Which compiler flag links FLINT?
Use -lflint; add include and library paths and an rpath if you installed to a non-default prefix.
Sources
- FLINT: Fast Library for Number Theory (read 2026-11-08)
- FLINT documentation: Building FLINT (read 2026-11-08)
- FLINT documentation: Your first program (read 2026-11-08)
- python-flint documentation: Install (read 2026-11-08)
- python-flint documentation: fmpz (read 2026-11-08)







