3

I'm trying to cross-compile VLC (from linux to windows) with gnutls support which in turn uses libgmp. I get linking errors for multiple definitions for symbols in libgmp (___gmpz_abs), for example, among countless others). I have in turn traced this back to libgnutls.a having multiple definitions of the same symbol, due to object files in gnutls each having their own definitions of gmp functions. The functions that are multiply defined are ones that libgmp is trying to do something tricky with inlining.

There's a lot of variation with inlining between different compilers, standards, and platforms, from what I can tell. It seems like libgmp is trying to use macros to handle this all properly but is failing. The end result is inline functions defined in gmp.h are getting copied into every object file in gnutls that uses it. I've looked at the actual compiler command lines that mingw is called with to create these object files, and I can't see anything wrong with it:

libtool: compile:  i686-w64-mingw32-gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I./../../gl -I./../../gl -I./../includes -I./../includes -I./../../gl -I./.. -I./../minitasn1 -I/home/jeremy/vlc/contrib/i686-w64-mingw32/include -I/home/jeremy/vlc/contrib/i686-w64-mingw32/include -g -c mpi.c -o mpi.o

in particular -std=gnu99 was suggested as a solution to similar problems elsewhere online, but obviously this is already being used by default.

It's unclear whose fault this is, mingw's libtool's gnutls's or gmp's

The question I need answered is: What flags or options do I need to configure or make gnutls with so that the inline function definitions will be properly handled?

Jeremy Salwen
  • 8,061
  • 5
  • 50
  • 73

2 Answers2

1

Those function are supposed to be inlined, but you appear to have built the library with optimization disabled, and so there is no inlining.

Try again with -O2 when you compile (and link).

ams
  • 24,923
  • 4
  • 54
  • 75
0

I cannot provide you a positive answer, but maybe this can be of some help to you From the GCC manual...

Note that certain usages in a function definition can make it unsuitable for inline substitution. Among these usages are: variadic functions, use of alloca, use of variable-length data types (see Variable Length), use of computed goto (see Labels as Values), use of nonlocal goto, and nested functions (see Nested Functions). Using -Winline warns when a function marked inline could not be substituted, and gives the reason for the failure.

In any case it's worth reading the whose section on inline functions

http://gcc.gnu.org/onlinedocs/gcc/Inline.html

jpmuc
  • 1,092
  • 14
  • 30
  • using -Winline seems to indicate that functions marked inline are all being properly substituted. At least, it does not output any warnings or messages. – Jeremy Salwen Mar 30 '13 at 03:14