User guide

NumPy User Guide, Release 1.9.0
FORTRAN ABI mismatch
The two most popular open source fortran compilers are g77 and gfortran. Unfortunately, they are not ABI compatible,
which means that concretely you should avoid mixing libraries built with one with another. In particular, if your
blas/lapack/atlas is built with g77, you must use g77 when building numpy and scipy; on the contrary, if your atlas
is built with gfortran, you must build numpy/scipy with gfortran. This applies for most other cases where different
FORTRAN compilers might have been used.
Choosing the fortran compiler
To build with g77:
python setup.py build --fcompiler=gnu
To build with gfortran:
python setup.py build --fcompiler=gnu95
For more information see:
python setup.py build --help-fcompiler
How to check the ABI of blas/lapack/atlas
One relatively simple and reliable way to check for the compiler used to build a library is to use ldd on the library. If
libg2c.so is a dependency, this means that g77 has been used. If libgfortran.so is a a dependency, gfortran has been
used. If both are dependencies, this means both have been used, which is almost always a very bad idea.
Disabling ATLAS and other accelerated libraries
Usage of ATLAS and other accelerated libraries in Numpy can be disabled via:
BLAS=None LAPACK=None ATLAS=None python setup.py build
Supplying additional compiler flags
Additional compiler flags can be supplied by setting the OPT, FOPT (for Fortran), and CC environment variables.
Building with ATLAS support
Ubuntu 8.10 (Intrepid) and 9.04 (Jaunty)
You can install the necessary packages for optimized ATLAS with this command:
sudo apt-get install libatlas-base-dev
If you have a recent CPU with SIMD suppport (SSE, SSE2, etc...), you should also install the corresponding package
for optimal performances. For example, for SSE2:
sudo apt-get install libatlas3gf-sse2
This package is not available on amd64 platforms.
NOTE: Ubuntu changed its default fortran compiler from g77 in Hardy to gfortran in Intrepid. If you are building
ATLAS from source and are upgrading from Hardy to Intrepid or later versions, you should rebuild everything from
scratch, including lapack.
6 Chapter 1. Introduction