Installing some NETLIB libraries on Unix-like systems

This page is about installing LAPACK, BLAS, MINPACK and SLATEC libraries (available from Netlib) on Unix-like systems (including Linux and Cygwin). Unfortunately, most linux distribution don't come with these libraries, so I hope this page helps.

Linux distributions

Debian

Debian has all these libraries : try to apt-get minpack for example. Luckily, the effort put into making and testing these packages can still be used on other distributions.

Redhat

Redhat (as of 7.3) has blas and lapack packages on the original CDs. You still have to build slatec and minpack by yourself.

Cygwin

Cygwin setup makes blas and lapack available. Only minpack and slatec must be recompiled.

Other distributions

Please send me information on the availability of these packages on other distributions.

MINPACK

Introduction

MINPACK is a library for solving nonlinear least-squares problems, and contaions a very good iplementation of the Levenberg-Marquardt algorithm.

The instructions below are for building the FORTRAN version of MINPACK (which can also be used from C) on a Unix-like system.

IMPORTANT: I also made a C/C++ version of Minpack, ditributed under the same license as Minpack, please check it out.

Building

v1=19961126
v2=16
wget http://ftp.debian.org/debian/pool/main/m/minpack/minpack_${v1}.orig.tar.gz
wget http://ftp.debian.org/debian/pool/main/m/minpack/minpack_${v1}-${v2}.diff.gz
gzip -dc minpack_${v1}.orig.tar.gz | tar xvf -
cd minpack-${v1}.orig
gzip -dc ../minpack_${v1}-${v2}.diff.gz | patch -p1 -d.
sh ./configure --disable-shared --prefix=/usr
make
make install prefix=`pwd`/tmproot/usr
install -D -m 644 ex/file06 tmproot/usr/share/doc/minpack-dev/minpack-documentation.txt
install -D -m 644 readme tmproot/usr/share/doc/minpack/readme
install -D -m 644 debian/copyright tmproot/usr/share/doc/minpack/copyright

All the files are installed under the directory tmproot, and should be moved to the proper installation prefix.

Packaging

I made a spec file for a RPM : download it, put minpack_19961126.orig.tar.gz and minpack_19961126-16.diff.gz in /usr/src/redhat/SOURCES, and call "rpmbuild -ba minpack.spec".

A binary package would include:

tmproot/usr/lib/lib*.so*
tmproot/usr/share/doc/minpack/readme
tmproot/usr/share/doc/minpack/copyright

A development package would include:

tmproot/usr/include/*
tmproot/usr/lib/lib*.a
tmproot/usr/lib/lib*.la 
tmproot/usr/lib/lib*.so
tmproot/usr/share/man/man3/*.3
tmproot/usr/share/doc/minpack-dev/minpack-documentation.txt

Example source code is in:

debian/Makefile debian/t*.c

SLATEC

Building

P=slatec
P2=slatec-dev
v1=4.1
v2=4
INSTALL=install
wget http://ftp.debian.org/debian/pool/main/s/slatec/slatec_${v1}-${v2}.tar.gz
wget -N http://devernay.free.fr/hacks/netlibs/slatec_${v1}-${v2}.tar.gz
gzip -dc slatec_${v1}-${v2}.tar.gz |tar xvf -
cd slatec-${v1}
make MA_N=${v1} MI_N=${v2} OPT="-O2 -g" F77="gfortran"

Note that I also provide a local mirror for the SLATEC debian distribution, since it seems to have disappeared frol the Debian pool.

In the last line, change the value of F77 if you use another Fortran compiler (g77, g95, ifort...). The files qc36j.f and dqc36j.f may not compile with some fortran compilers (e.g. g95). In that case, remove qc36j.o and dqc36j.o from slatec-4.1/src/chk/Makefile.

Installing

	${INSTALL} -d debian/tmp/usr/share/doc/${P}
	${INSTALL} -d debian/tmp/usr/lib
# Install docs in proper directory and gzip them
#
	cp debian/changelog debian/tmp/usr/share/doc/${P}/changelog.Debian
#	cp ChangeLog debian/tmp/usr/share/doc/${P}/changelog
	${INSTALL} -m 644 debian/README.debian debian/tmp/usr/share/doc/${P}
	${INSTALL} -m 644 readme debian/tmp/usr/share/doc/${P}/README
	gzip -9v debian/tmp/usr/share/doc/${P}/*
# but don't gzip the copyright statement
#
	cp debian/copyright debian/tmp/usr/share/doc/${P}/copyright
# Install shared library
#
	strip --strip-unneeded lib${P}.so.${v2}
	${INSTALL} -m 644 lib${P}.so.${v2} debian/tmp/usr/lib/.

# Second round...package slatec-dev......................................
# Create additional installation directories
#
	${INSTALL} -d debian/tmp/usr/share/doc/${P2}
	${INSTALL} -d debian/tmp/usr/lib
# Install docs in proper directory and gzip them
#
	${INSTALL} -m 644 debian/README.debian debian/tmp/usr/share/doc/${P2}
	cp debian/changelog debian/tmp/usr/share/doc/${P2}/changelog.Debian
	# Install package docs
	${INSTALL} -d debian/tmp/usr/share/doc/${P2}/
	${INSTALL} -m 644 install debian/tmp/usr/share/doc/${P2}/INSTALL
	${INSTALL} -m 644 readme debian/tmp/usr/share/doc/${P2}/README
	${INSTALL} -m 644 doc/* debian/tmp/usr/share/doc/${P2}/
	gzip -9fv debian/tmp/usr/share/doc/${P2}/*
# but don't gzip the copyright statement
#
	cp debian/copyright debian/tmp/usr/share/doc/${P2}/copyright
# Install test files
	${INSTALL} -d  debian/tmp/usr/share/doc/${P2}/tests
	${INSTALL} -m 644 src/chk/*.f src/chk/Makefile src/chk/README.tests  debian/tmp/usr/share/doc/${P2}/tests
	${INSTALL} -m 755 src/chk/dotests debian/tmp/usr/share/doc/${P2}/tests
	gzip -9vf debian/tmp/usr/share/doc/${P2}/tests/*
# Install static library
#
	strip --strip-debug lib${P}.a
	${INSTALL} -m 644 lib${P}.a debian/tmp/usr/lib/.
# Create .so link
#
	ln -s lib${P}.so.${v2} debian/tmp/usr/lib/lib${P}.so

Frederic Devernay
Last modified: Thu Apr 26 11:17:14 CEST 2012