library dependencies and --as-needed

Brian Gough bjg@gnu.org
Thu Jan 29 15:32:00 GMT 2009


Hello, 

I'd like to ask for advice on library dependencies and the --as-needed
linker flag in the GSL project (GNU Scientific Library).

Our main lib file needs to call an external library (BLAS) for vector
operations.  We want people to be able to choose different BLAS
libraries when they link their applications, e.g.

   $ gcc main.c -lgsl -lcblas -lm  # "cblas" can be ATLAS, Intel, AMD, etc

Thefore we don't specify any dependency on the external BLAS with
libtool, since its location would get hard-coded in the GSL shared
library.

This works fine except when the user links their application
--as-needed, which misses the BLAS functions as they are only used in
libgsl.so and (typically) not in the user's object file.

Is there a recommended way to handle this situation?  

It seems like it would work if the search with --as-needed was
recursive, is there any conceptual reason for it not to do that?

Thanks.

-- 
Brian Gough
(GSL Maintainer)



More information about the Binutils mailing list