From: nisse@lysator.liu.se (Niels Möller) Date: Fri, 29 Nov 2013 14:02:05 +0100 Cc: Nettle Crypto Library nettle-bugs@lists.lysator.liu.se
Alexey Pavlov alexpux@gmail.com writes:
2013/11/29 Niels Möller nisse@lysator.liu.se:
What failed? Can I repost your message to the list?
I do it already. I receive subscribing message now.
Ok. I'm now cc:ing the list. Context: Link error when building a dynamic libnettle.dll and libhogweed.dll, and statically linking to libgmp.a.
AFAIK, this cannot possibly work on Windows. A DLL cannot depend on a static library. And if the linker is clever enough to copy the entire libgmp into the DLL, you will have trouble while linking programs against such a DLL, like the trouble we see here.
So you're building shared libraries for nettle, but you have a static gmp library? The way I understand the error, the used gmp functions gets copied into libhogweed.dll. Not sure if that is the best behavior.
No, the symbols from libgmp are copied into the libhogweed _import_ library libhogweed.dll.a. The import library is a static library.
The symbol __gmp_sub_n is defined in some object file included in libgmp.a, and nowhere in the nettle source or object code (and mini-gmp.c doesn't count, it's not involved in the link, and it uses different linker symbol names than the real gmp).
This object file gets copied from libgmp.a into libhogweed.dll by the linker. Not sure if this is right; -lgmp was added to the libhogweed link command primarily to get dependencies between *shared* libraries right.
You then link the executable ecc-mod-test.exe with -lhogweed and -lgmp. The linked sees two definitions of the symbol __gmpn_sub_n, one in libgmp.a, and one in libhogweed.dll, and it considers this an error.
What I don't understand, is why, in (3) above, the linker doesn't just ignore the object in libgmp.a which defines the symbol.
It could be because the module sub_n.o, which is taken from libgmp.a, is needed to satisfy other externals, and that module brings with it a second definition of __gmpn_sub_n.
But anyway, I think this is unworkable on Windows. If Alexey doesn't want dependencies on shared libraries, he needs to build static libraries from libhogweed and libnettle (I think --disable-shared at configure time will achieve that effect).