[Developers] Library-specific linker flags

Erik Schnetter schnetter at cct.lsu.edu
Sun Feb 10 15:08:21 CST 2008

On Queen Bee and probably on related systems, it is necessary to link  
certain libraries statically, but others dynamically.  The  
configuration mechanism in Cactus can currently not handle this.

In Cactus, external libraries have three configuration variables  
associated with them, one defining the include path, one defining the  
library path, and one listing the library names.  It is not possible  
to add linker flags before or after the library names, since library  
names unconditionally have a "-l" prefix attached.  For example, the  
configuration settings

BLAS_DIR  = /usr/local/compilers/Intel/mkl-10.0/lib/em64t
BLAS_LIBS = mkl_em64t guide   pthread

are translated to

GENERAL_LIBRARIES = -L/usr/local/compilers/Intel/mkl-10.0/lib/em64t - 
lmkl_em64t -lguide -lpthread

I would like to add the flags -Bstatic and -Bdynamic before and after  
the library name, respectively.  I suggest to update the prefix- 
attaching mechanism so that it add prefixes to library names, but  
leaves flags alone.  This allows me to write

BLAS_DIR  = /usr/local/compilers/Intel/mkl-10.0/lib/em64t
BLAS_LIBS = -Bstatic mkl_em64t guide -Bdynamic   pthread

which would be translated to

GENERAL_LIBRARIES = -L/usr/local/compilers/Intel/mkl-10.0/lib/em64t - 
Bstatic -lmkl_em64t -lguide -Bdynamic -lpthread

which is the correct list of options for Queen Bee.

The patch below to lib/make/configure.in achieves the above:

+# How to link in the non-Cactus libraries:
+# Add -L and -l prefixes, but only for file names;
+# allow arbitrary options in between
-: ${GENERAL_LIBRARIES='$(LIBDIRS:%=-L%) $(LIBS:%=-l%)'}
+: ${GENERAL_LIBRARIES='$(patsubst -L-%,-%,$(LIBDIRS:%=-L%)) $ 
(patsubst -l-%,-%,$(LIBS:%=-l%))'}


Erik Schnetter <schnetter at cct.lsu.edu>   http://www.cct.lsu.edu/ 

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://www.cactuscode.org/pipermail/developers/attachments/20080210/34a174f4/attachment.bin 

More information about the Developers mailing list