Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

FLINT (Fast Library for Number Theory): Install and First Program

How to install FLINT, the Fast Library for Number Theory, via C or python-flint, and verify a first computation against known output.

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

  1. Include the headers flint/flint.h, flint/fmpz.h and flint/fmpz_factor.h (the tutorial’s first program uses these three).
  2. Declare the integer type with fmpz_t and initialise it with fmpz_init. Factorisation data uses fmpz_factor_t with fmpz_factor_init.
  3. Compute 30! with fmpz_fac_ui(a, 30) and print it with flint_printf("30! = %{fmpz}
    ", a)
    .
  4. Build 2^60 − 1 with fmpz_one, fmpz_mul_2exp(b, b, 60) and fmpz_sub_ui(b, b, 1); take the GCD with fmpz_gcd(g, a, b); factor with fmpz_factor(fac, b) and fmpz_factor_print(fac).
  5. 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.h or mpfr.h. Install the development packages (libgmp-dev libmpfr-dev on Debian or Ubuntu), or point configure at them with --with-gmp=DIR and --with-mpfr=DIR.
  • Program compiles but cannot find libflint at run time. You installed to a non-default prefix. Add -Wl,-rpath,<prefix>/lib when linking, as in the official tutorial.
  • Static linking errors. The building guide says a static link also needs -lmpfr -lgmp -lpthread -lm in addition to -lflint.
  • pip install python-flint tries 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.sh first.

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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about FLINT (Fast Library for Number Theory): Install and First Program

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →