Compiling LAPACK

From URCFwiki
Jump to: navigation, search

NOTE: You do not need to compile LAPACK. Hardware-specific optimized versions have been installed on Proteus. This is a guide meant for Proteus systems administrators.

cmake?

A comment by emhj on that blogspot post says:

For newer versions of LAPACK, setting -DBUILD_SHARED_LIBS=ON when calling cmake will also build shared libraries.

Example cmake command, assuming that ../lapack-3.5.0 is the relative path to the source code:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lapack-3.5.0 -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=ON ../lapack-3.5.0

As usual with cmake, can use "ccmake" to get a TUI to edit the various build options.

Edit make.inc

  • Check the INSTALL subdirectory for examples.

Compiling LAPACK as a Shared Library

This is based on the content from the link in the "See Also" section to serve as redundancy, since that link is from 2010, and could disappear. Also, the makefile structure of LAPACK has changed since then.

Files to be Modified

These three files have to be modified:

  1. make.inc
  2. SRC/Makefile
  3. Makefile

make.inc

Add "-fPIC" to the following:

  • FORTRAN
  • OPTS
  • NOOPT
  • LOADER

Optionally add "-pipe" to the following:

  • FORTRAN
  • LOADER

For convenience, define PREFIX:

  • PREFIX=/opt

Define new macro for the linker:

LINKER = gfortran

Define new macro for the shared library (adjust version):

LAPACKSOLIB = liblapack.so.3.8.0

SRC/Makefile

Add the shared library as a new target:

all: ../$(LAPACKLIB)  ../$(LAPACKSOLIB)

Add rule for building the shared library:

../$(LAPACKSOLIB): $(ALLOBJ) $(ALLXOBJ) $(DEPRECATED)
        $(LINKER) -shared -Wl,-soname,$@ -o $@ $^

Makefile

Add rules to copy the generated shared library to the right places (makes use of PREFIX defined earlier):

install: all
        cp $(LAPACKSOLIB) $(PREFIX)/lib
        ln -s $(PREFIX)/lib/$(LAPACKSOLIB) $(PREFIX)/lib/liblapack.so.3.8
        ln -s $(PREFIX)/lib/$(LAPACKSOLIB) $(PREFIX)/lib/liblapack.so.3
        ln -s $(PREFIX)/lib/$(LAPACKSOLIB) $(PREFIX)/lib/liblapack.so
        cp *.a $(PREFIX)/lib
        mkdir -p $(PREFIX)/man
        cp -R DOCS/man/man3 $(PREFIX)/man

See Also