Can I stop linking the same library twice?

Dr. David Kirkby david.kirkby@onetel.net
Sun Dec 13 19:38:00 GMT 2009


I have seen issues in the Sage mathematics software

http://www.sagemath.org/

where problems arise if a library included in Sage is installed on the system 
too. Sage included the source for all the libraries it needs (e.g. readline), in 
case the system does not have that library. That sometimes causes problems, if 
the option "-L $SAGE_HOME/local/lib" is added and the library is also on the 
system.

Is there a way to specify that only the first copy of the library is linked, and 
not any other copies gcc might find? Readline is not the only library where 
issues have arisen (OpenSSL libraries on OpenSolaris is another example).

I'd rather some way of doing this which is not GCC specific, and certainly not 
specific to the GNU linker, as on Solaris the Sun linker works better, and in 
any case we hope to support non-GNU compilers too. But in the short term, 
anything that works with gcc, even if not with other compilers, would be useful.

Dave



More information about the Gcc-help mailing list