gnulib and static libraries

2010-07-09 Thread Simon Josefsson
A problem that have been (I believe) ignored for a long time is how to
handle namespace when using gnulib in project that provides static
libraries.  Here is an example of where this causes problems:

http://lists.gnu.org/archive/html/bug-wget/2010-07/msg00010.html
http://thread.gmane.org/gmane.comp.web.wget.general/9539

In this case, GnuTLS uses the read-file module from gnulib, and it ends
up being exported in a static GnuTLS library.  GNU Wget also has a
function called read_file, and things break when linking.

Should `gnulib-tool --import' create AC_DEFINE's to map each global
gnulib function symbol into some application provided namespace?
E.g. `gnulib-tool --import --symbol-prefix _gnutls'?  This would then
create something like this:

AC_DEFINE([read_file], [__gnutls_read_file])

Maintaining the list of global gnulib functions will be a hassle
though.  Could this be automated?

Are there better solutions?

I have some vague memory that this has been discussed before (I may even
have brought it up) but I can't find anything in the gnulib
documentation around this, so I'm guessing it has not been resolved.
But I am hoping that I'm wrong. :-)

/Simon



Re: gnulib and static libraries

2010-07-09 Thread Bruno Haible
Hi Simon,

> In this case, GnuTLS uses the read-file module from gnulib, and it ends
> up being exported in a static GnuTLS library.  GNU Wget also has a
> function called read_file, and things break when linking.
> ...
> I have some vague memory that this has been discussed before (I may even
> have brought it up)

Yes, we discussed this topic in the thread started in
.

I had been pointing you to gettext/gettext-tools/libgettextpo/Makefile.am;
nowadays the same technique is also used in libunistring/lib/Makefile.am.
In particular, look at this commit:
http://git.savannah.gnu.org/gitweb/?p=libunistring.git;a=commitdiff;h=d598f9e1e016735397e9dca53b436d13c6fb28f3

> Should `gnulib-tool --import' create AC_DEFINE's to map each global
> gnulib function symbol into some application provided namespace?
> E.g. `gnulib-tool --import --symbol-prefix _gnutls'?  This would then
> create something like this:
> 
> AC_DEFINE([read_file], [__gnutls_read_file])
> 
> Maintaining the list of global gnulib functions will be a hassle
> though.  Could this be automated?

Possibly. In the cases I needed, I did not have to hide all global symbols
coming from gnulib, but only some of them. I don't  know whether in the
case you mention things get simple enough that gnulib could generate
the redirections in config.h.

Bruno