WIN64: 'one or more multiply defined symbols found' errors for shared GMP builds using Windows ICC and MSVC
marc.glisse at inria.fr
Sat Jan 27 20:50:15 UTC 2018
On Sat, 27 Jan 2018, sav_ix at ukr.net wrote:
> Hello everyone,
> For GMP builds using Windows ICC and MSVC got errors:
> get_ui.obj : error LNK2005: __gmpz_get_ui already defined in bin_ui.obj
> neg.obj : error LNK2005: __gmpz_neg already defined in bin_ui.obj
> add.obj : error LNK2005: __gmpn_add already defined in add.obj
> add_1.obj : error LNK2005: __gmpn_add_1 already defined in add_ui.obj
> sub.obj : error LNK2005: __gmpn_sub already defined in sub.obj
> sub_1.obj : error LNK2005: __gmpn_sub_1 already defined in sub.obj
> neg.obj : error LNK2005: __gmpn_neg already defined in sub.obj
> cmp.obj : error LNK2005: __gmpn_cmp already defined in cmp.obj
> zero_p.obj : error LNK2005: __gmpn_zero_p already defined in combit.obj
> Creating library .libs/gmp.lib and object .libs/gmp.exp
> .libs\gmp-10.dll : fatal error LNK1169: one or more multiply defined symbols found
> (log added in attachment).
> Reproduced for:
> - shared GMP builds using Windows ICC and MSVC,
> not reproduced for:
> - static GMP builds using Windows ICC and MSVC,
> - shared GMP builds using mingw-w64,
> - shared MPFR and libiconv builds using Windows ICC and MSVC.
> - Windows 10 x64,
> - ICC 2018 Update 1,
> - MSVC 2017 15.5.0,
> - Windows SDK 10.0.16299.15,
> - mingw-w64 x86_64 posix seh 7.2.0,
> - MSYS2 x86_64 20170918,
> - GMP-6.1.99-dev-r17531.
> The workaround is to use '-FORCE:MULTIPLE' flag, which results to warning:
> .libs\gmp-10.dll : warning LNK4088: image being generated due to /FORCE option; image may not run
> Even it has no visible effect on 'make check' run, compared to static builds or builds using mingw-w64, would be nice to get rid of it.
> Since Windows ICC and MSVC are not officially supported by GMP, it's hard to expect, that this issue would be fixed for them.
> But for a few past years a number of such errors decreased from about a hundred to nine, which could be a result of refactoring in GMP code. If such a refactoring took place, and this errors points to its flaws, would be nice to finish it completely.
Maybe newer versions of your compiler only show the first 10 errors
instead of an unlimited number?
Anyway, it sounds like the definitions of __GMP_EXTERN_INLINE /
__GMP_EXTERN_INLINE in gmp.h (gmp-h.in in the sources) are not the right
ones for MSVC, you want to investigate what would be good for that
compiler. Or maybe using VC++ instead of VC would be enough.
More information about the gmp-bugs