ld: fatal: symbol `__gmpz_abs' is multiply-defined:

Marc Glisse marc.glisse at normalesup.org
Wed Jun 24 19:40:15 CEST 2009

On Wed, 24 Jun 2009, Torbjorn Granlund wrote:

> Marc Glisse <marc.glisse at normalesup.org> writes:
>  Yes, I think it was really meant to be "inline" instead of "extern
>  inline".
> Have you checked that the pesky Sun^H^H^HOracle compilers don't put
> these functions in *every* object file?  That would be mad.

Yes. And it is what the C99 standard says. With "inline", the function may 
be inlined, but you never get a separate function definition in the object 
file. With "extern inline", you always get one (and so get an error for 
multiple definitions). With "static inline", object files where the 
function is used but wasn't inlined contain a private implementation of 
the function, so you may end up with many copies, that don't interfere 
with each other. C++ "inline" is similar to C99 "static inline" except 
that only one copy of the code is kept when you link it all together. C99 
"inline" is thus the only one where the implementation in libgmp.so is 
ever used.

Sun has an extension that makes the C99 "extern inline" a bit closer to 
the C++ "inline" by merging all such definitions at link time instead of 
giving an error for multiple definitions. It still gives an error if you 
link an object with an "extern inline" definition of a function and one 
with a regular definition of the same function (which is what happens 
during the gmp build).

Marc Glisse

More information about the gmp-bugs mailing list