mahmood mahmood - 4 months ago 13
Linux Question

Makefile searching for a library file

In an auxiliary make file (named

arch.make
) which contains some libraries, I have wrote

FFLAGS=-g -O2
FPPFLAGS= -DMPI -DFC_HAVE_FLUSH -DFC_HAVE_ABORT
LDFLAGS=-L/export/apps/computer/lapack-3.2

LAPACK_LIBS=-llapack_LINUX
LIBS=$(LAPACK_LIBS)


Then, the Makefile contains

siesta: check-siesta what version $(MPI_INTERFACE) $(FDF) $(WXML) $(XMLPARSER) \
$(COMP_LIBS) $(ALL_OBJS)
$(FC) -o siesta \
$(LDFLAGS) $(ALL_OBJS) $(FDF) $(WXML) $(XMLPARSER) $(MPI_INTERFACE)\
$(COMP_LIBS) $(FoX_LIBS) $(LIBS)


Other variables are fine. Please note
$(LIBS)
and
$(LDFLAGS)
which are defined in
arch.make
.

That library file really exists according to

root@cluster:ObjPar# ls /export/apps/computer/lapack-3.2/lapack_LINUX.a -l
-rw-r--r-- 1 root root 18296682 Jul 10 20:50 /export/apps/computer/lapack-3.2/lapack_LINUX.a


However, the make process exits with the following error

......
dc_lapack.a `FoX/FoX-config --libs --wcml` -llapack_LINUX -lblas
/usr/bin/ld: cannot find -llapack_LINUX
collect2: ld returned 1 exit status


There are many lines before that but I omitted them.

What should I do?

Answer

The linker does not find a file called liblapack_LINUX.a or liblapack_LINUX.so. You will need to point to the file directly with

LAPACK_LIBS=/export/apps/computer/lapack-3.2/lapack_LINUX.a

The LDFLAGS variable may be removed.

You are likely to have to link the BLAS library in this way as well if the library is not called libblas.a or libblas.so. The order of linking may also be important. BLAS before LAPACK.