Linux HOWTOs

About | Home | Search


HOWTO: gmp
Description: _G_NU _M_ultiple _P_recision Arithmetic Library
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GMP 6.1.2
# =========
# As I write this, version 6.1.2 is considered the current stable release

# Slackware 13.37: gmp 5.0.1
# Slackware 14.0: gmp 5.0.5
# Slackware 14.1: gmp 5.1.3
# Slackware 14.2: gmp 6.1.1

# Prerequisites:
# m4
# readline
# bison
# flex

# If you have trouble downloading it from the URL below, try this instead:
# http://ftp.gnu.org/gnu/gmp/

# The release announcement is here:
# https://gmplib.org/list-archives/gmp-announce/2016-December/000047.html

# Get it
cd
test -f installed/gmp-6.1.2.tar.lz && mv installed/gmp-6.1.2.tar.lz .
test ! -f gmp-6.1.2.tar.lz &&
 wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz

# Verify tarball w/ sha1sum:
# (this came from my gpg-verified tarball)
echo "27b6d2c560b3552ea3e2f1dfa1394c2d36f09ba2  gmp-6.1.2.tar.lz" | \
sha1sum -c

# Verify tarball w/ sha256sum:
# (this also came from my gpg-verified tarball)
echo "12fed0532d440d2dc902e64f016aa89a33af6044b90bd1f7bca7396635105d\
bb  gmp-6.1.2.tar.lz" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 28C67298 > /dev/null 2>&1 || gpg --recv-keys 28C67298 ) &&
 wget -nc ftp://ftp.gmplib.org/pub/gmp-6.1.2/gmp-6.1.2.tar.lz.sig &&
  gpg --verify gmp-6.1.2.tar.lz.sig && rm gmp-6.1.2.tar.lz.sig

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "gmp-*" -exec rm -r {} \;
tar xv --lzip -f ~/gmp-6.1.2.tar.lz
cd gmp-6.1.2
test $UID = 0 && chown -R root:root .

# Configure the build
test $(uname -m) = 'x86_64' &&
./configure --prefix=/usr --infodir=/usr/info --libdir=/usr/lib64 \
--with-gnu-ld --enable-cxx

# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --infodir=/usr/info --with-gnu-ld --enable-cxx

# Build it
make

# Check the build, takes a while
make check

# Become root to install it
su

# Remove old files, install the new version
# This will leave behind libgmp, libgmpxx because they are also in the
# 'aaa_elflibs' package
test -x /sbin/removepkg && /sbin/removepkg gmp

# Remove this if you have an older version installed that included it
# (if you used --enable-mpbsd) prior to 5.1.1
rm -f /usr/include/mp.h /usr/lib/libmp.*

# Remove old version library files if nothing else is using them
( cd /usr/lib ; rm -f libgmp.* libgmpxx.* )
test -d /usr/lib64 &&
 ( cd /usr/lib64 ; rm -f libgmp.* libgmpxx.* )

# Install it
make install
ldconfig

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become your non-root user again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/gmp-*.tar.*
mv gmp-6.1.2.tar.lz installed/


# If you ever want to uninstall GMP, this should do it:
cd
su
test -d src/gmp-* && ( cd src/gmp-* ; make uninstall )
( cd /usr/include ; rm -f gmp.h mp.h gmpxx.h )
for libdir in /usr/lib /usr/lib64;
do
  test -d $libdir &&
   ( cd /usr/lib ; rm -f libgmp.* libgmpxx.* libmp.* )
done
rm -f /usr/info/gmp.info
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "gmp-*" -exec rm -r {} \;
rm -f ~/installed/gmp-*.tar.*

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>