Compiling Octave with 64-bit Indexing (GNU Octave (version 11.2.0))

### E.3 Compiling Octave with 64-bit Indexing ¶

Note: the following only applies to systems that have 64-bit pointers. Configuring Octave with `--enable-64` cannot magically make a 32-bit system have a 64-bit address space.

On 64-bit systems, Octave uses 64-bit integers for indexing arrays by default. If the configure script determines that your BLAS library uses 32-bit integers, then operations using the following libraries are limited to arrays with dimensions that are smaller than 2^{31} elements:

- BLAS
- LAPACK
- QRUPDATE
- SuiteSparse
- SUNDIALS IDA
- ARPACK

Additionally, the following libraries use `int` internally, so maximum problem sizes are always limited:

- GLPK
- Qhull

Except for GLPK and Qhull, these libraries may also be configured to use 64-bit integers, but most systems do not provide packages built this way. If you wish to experiment with large arrays, the following information may be helpful.

To determine the integer size of the BLAS library used by Octave, the following code can be executed:

    clear all;
    N = 2^31;
    ## The following line requires about 8 GB of RAM!
    a = b = ones (N, 1, "single");
    c = a' * b

If the BLAS library uses 32-bit integers, an error will be thrown:

    error: integer dimension or index out of range for Fortran
    INTEGER type

Otherwise, if the BLAS library uses 64-bit integers, the result is:

    c = 2^31 = 2147483648

Note that the test case above usually requires twice the memory, if a and b are not assigned by `a = b = …`. Note further, that the data type `single` has a precision of about 23 binary bits. In this particular example no rounding errors occur.

Generally, it is best to have all of these libraries in versions that support 32-bit indexing, or all of these libraries must support 64-bit indexing. Mixing libraries with 64-bit indexing with libraries with 32-bit indexing can cause unpredictable behavior including program crashes with possible loss of data.

The following instructions were tested with the development version of Octave and GCC 4.3.4 on an x86_64 Debian system and may be out of date now. Please report any problems or corrections on the Octave bug tracker.

The versions listed below are the versions used for testing. If newer versions of these packages are available, you should try to use them, although there may be some differences.

All libraries and header files will be installed in subdirectories of `$prefix64` (you must choose the location of this directory).

- BLAS and LAPACK (http://www.netlib.org/lapack)

  Reference versions for both libraries are included in the reference LAPACK 3.2.1 distribution from http://www.netlib.org/.

  - Copy the file `make.inc.example` and name it `make.inc`. The options `-fdefault-integer-8` and `-fPIC` (on 64-bit CPU) have to be added to the variable `OPTS` and `NOOPT`.
  - Once you have compiled this library make sure that you use it for compiling Suite Sparse and Octave. In the following we assume that you installed the LAPACK library as $prefix64/lib/liblapack.a.
- QRUPDATE (https://sourceforge.net/projects/qrupdate)

  In the `Makeconf` file:

  - Add `-fdefault-integer-8` to `FFLAGS`.
  - Adjust the BLAS and LAPACK variables as needed if your 64-bit aware BLAS and LAPACK libraries are in a non-standard location.
  - Set `PREFIX` to the top-level directory of your install tree.
  - Run `make solib` to make a shared library.
  - Run `make install` to install the library.
- SuiteSparse (http://faculty.cse.tamu.edu/davis/suitesparse.html)

  Pass the following options to `make` to enable 64-bit integers for BLAS library calls. On 64-bit Windows systems, use `-DLONGBLAS="long long"` instead.

      CFLAGS='-DLONGBLAS=long'
      CXXFLAGS='-DLONGBLAS=long'

  The SuiteSparse makefiles don’t generate shared libraries. On some systems, you can generate them by doing something as simple as

      top=$(pwd)
      for f in *.a; do
        mkdir tmp
        cd tmp
        ar vx ../$f
        gcc -shared -o ../${f%%.a}.so *.o
        cd $top
        rm -rf tmp
      done

  Other systems may require a different solution.

- SUNDIALS IDA (https://computing.llnl.gov/projects/sundials/ida)

  When configuring with `cmake` add the flag `-DSUNDIALS_INDEX_SIZE=64`.

- ARPACK (https://forge.scilab.org/index.php/p/arpack-ng/)
  - Add `-fdefault-integer-8` to `FFLAGS` when running configure.
  - Run `make` to build the library.
  - Run `make install` to install the library.
- ATLAS instead of reference BLAS and LAPACK

  Suggestions on how to compile ATLAS would be most welcome.

- GLPK
- Qhull (http://www.qhull.org)

  Both GLPK and Qhull use `int` internally so maximum problem sizes may be limited.

- Octave

  Octave’s 64-bit index support is activated with the configure option `--enable-64`.

      ./configure \
        LD_LIBRARY_PATH="$prefix64/lib" \
        CPPFLAGS="-I$prefix64/include" LDFLAGS="-L$prefix64/lib" \
        --enable-64

  You must ensure that all Fortran sources, except those in the `liboctave/external/ranlib` directory, are compiled such that INTEGERS are 8-bytes wide. If you are using gfortran, the configure script should automatically set the Makefile variable `F77_INTEGER_8_FLAG` to `-fdefault-integer-8`. If you are using another compiler, you must set this variable yourself. You should NOT set this flag in `FFLAGS`, otherwise the files in `liboctave/external/ranlib` will be miscompiled.

- Other dependencies

  Probably nothing special needs to be done for the following dependencies. If you discover that something does need to be done, please submit a bug report.

  - pcre
  - zlib
  - hdf5
  - fftw3
  - cURL
  - GraphicsMagick++
  - OpenGL
  - freetype
  - fontconfig
  - fltk