bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple definition of gnulib symbols


From: Bruno Haible
Subject: Re: Multiple definition of gnulib symbols
Date: Thu, 26 Apr 2007 01:04:11 +0200
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> It seems clear that the problem is that both libgnutls and libgsasl  
> contains the same gnulib symbols.

Uh, you are jumping to the conclusion rather quickly.

First of all, can the reporter reproduce the problem also when building
without the -ffunction-sections option?

Second, the error message is about gc-libgcrypt.o and gc-gnulib.o in
particular, not about gnulib in general. These two object files define
different, but partially overlapping sets of symbols:
  - gc-libgcrypt.o defines gc_hash_hmac_setkey, gc-gnulib.o doesn't.
  - both define gc_init.
Possibly there are also differences due to the version of gnulib used in
the two libraries /usr/lib/libgnutls.a and .libs/libgsasl.a . It would
help if your reporter could give you the output of "nm" on these two
libraries.

> Or is there some libtool/ld/etc setting that gnulib or my  
> projects should use, to avoid causing this situation?

Such errors when linking statically typically occur when you have object
files defining more than one symbol. The rest of gnulib doesn't see this
kind of error because most .o files define one and only one function.

How can you turn a module that defines 10 functions into a module that
defines just 1 symbol? Combine the 10 functions into a vtable (= struct
containing function pointers). See the 'list' module for an example:
  - The header file defines inline functions or macros that access individual
    elements of this function pointer table,
  - Any .o file only defines a named function pointer table.
(This is not to say that here you won't have versioning problems: If at
some moment you add an 11th function pointer, two compiled versions of
this module will be binary incompatible.)

> One solution might be for gnulib-tool to change the namespace of all  
> gnulib functions to 'gnutls_*' and 'gsasl_*' respectively, when  
> importing them into each project.

Yes. Ralf was the first one to realize the need for such a renaming. It can
be done in a Makefile.am rule without special help from gnulib-tool. See
gettext/gettext-tools/libgettextpo/Makefile.am.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]