undefined reference to ‘__gmpn_sub_n’ #111

issue Bushstar openend this issue on November 20, 2014
  1. Bushstar commented at 2:26 pm on November 20, 2014: none

    I’m a tad stuck now using secp256k1 on Windows which makes life harder. I have compiled GMP-6.0.0a and used the static lib to compile secp256k1. Everything goes without fault. However when I use the secp256k1 in a coin I get the errors below when compiling. Any help with this would be appreciated, I have tried linking lgmp straight into the client to see if this resolves the issue without joy.

    C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_sub': c:/mingw32/i686-w64-mingw32/include/gmp.h:2168: undefined reference to__gmpn_sub_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2168: undefined reference to __gmpn_sub_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_num_set_bin’: c:\deps\secp256k1/src/num_gmp_impl.h:73: undefined reference to __gmpn_set_str' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_num_shift’: c:\deps\secp256k1/src/num_gmp_impl.h:267: undefined reference to __gmpn_rshift' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: Makefile.Release:303: recipe for target ‘release\deepcoin-qt.exe’ failed mingw32-make[1]: Leaving directory ‘E:/GitHub/build-deepcoin-qt-Desktop_4_8_5-Release’ Makefile:34: recipe for target ‘release’ failed c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_fe_reduce’: c:\deps\secp256k1/src/field_gmp_impl.h:133: undefined reference to __gmpn_addmul_1' c:\deps\secp256k1/src/field_gmp_impl.h:134: undefined reference to__gmpn_addmul_1’ c:\deps\secp256k1/src/field_gmp_impl.h:137: undefined reference to __gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:140: undefined reference to__gmpn_addmul_1’ C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_sqr': c:\deps\secp256k1/src/field_gmp_impl.h:159: undefined reference to__gmpn_sqr' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul': c:\deps\secp256k1/src/field_gmp_impl.h:151: undefined reference to__gmpn_mul_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_mod_inverse': c:\deps\secp256k1/src/num_gmp_impl.h:144: undefined reference to__gmpn_gcdext' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_sub': c:/mingw32/i686-w64-mingw32/include/gmp.h:2168: undefined reference to__gmpn_sub_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_get_bin': c:\deps\secp256k1/src/num_gmp_impl.h:58: undefined reference to__gmpn_get_str' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_mul': c:\deps\secp256k1/src/num_gmp_impl.h:231: undefined reference to__gmpn_mul' c:\deps\secp256k1/src/num_gmp_impl.h:235: undefined reference to __gmpn_copyi' c:\deps\secp256k1/src/num_gmp_impl.h:229: undefined reference to__gmpn_mul' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_mod': c:\deps\secp256k1/src/num_gmp_impl.h:108: undefined reference to__gmpn_tdiv_qr' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul_int': c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul_int': c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul_int': c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul_int': c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_fe_mul_int’: c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_fe_mul_int’: c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_fe_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_fe_mul_int’: c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to __gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o):c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: more undefined references to__gmpn_add_n’ follow C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_fe_mul_int': c:\deps\secp256k1/src/field_gmp_impl.h:116: undefined reference to__gmpn_mul_1' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function _gmpn_add': c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In functionsecp256k1_num_split’: c:\deps\secp256k1/src/num_gmp_impl.h:350: undefined reference to __gmpn_copyi' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_add’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to__gmpn_add_n' c:/mingw32/i686-w64-mingw32/include/gmp.h:2129: undefined reference to __gmpn_add_n' C:/deps/secp256k1/.libs\libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function_gmpn_sub’: c:/mingw32/i686-w64-mingw32/include/gmp.h:2168: undefined reference to `__gmpn_sub_n'

  2. sipa commented at 2:28 pm on November 20, 2014: contributor
  3. Bushstar commented at 2:39 pm on November 20, 2014: none

    The error above I get when trying to compile the Qt client using Mingw gcc 4.8.2. I read something from Feb this year stating that there were some issues with libgmp and some versions of gcc. I will update to see if this helps and report back.

    EDIT: I found this, were you referencing it? https://github.com/theuni/secp256k1

  4. Bushstar commented at 7:08 pm on November 20, 2014: none

    No luck, moved to gcc 4.9.1 with the same result. Statically compiled all libs from scratch but still get the same errors. I also tried the @theuni repo of this software and got the same result.

    Building GMP in MSYS with… ./configure make

    …and secp256k1 with… ./autogen.sh ./configure make

    From the secp256k1 configure… checking gmp.h usability… yes checking gmp.h presence… yes checking for gmp.h… yes checking for __gmpz_init in -lgmp… yes checking openssl/crypto.h usability… no checking openssl/crypto.h presence… no checking for openssl/crypto.h… no configure: Using field implementation: gmp configure: Using bignum implementation: gmp configure: Using scalar implementation: 32bit

    When compiling I get the following… User@Melody /c/deps/secp256k1 $ make CC libsecp256k1_la-secp256k1.lo CCLD libsecp256k1.la libtool: link: warning: undefined symbols not allowed in i686-pc-mingw32 shared libraries CC bench_verify.o CCLD bench_verify.exe CC bench_sign.o CCLD bench_sign.exe CC bench_inv.o CCLD bench_inv.exe CC tests-tests.o src/tests.c: In function ‘main’: src/tests.c:1033:13: warning: implicit declaration of function ’time’ [-Wimplici t-function-declaration] seed = time(NULL) * 1337; ^ src/tests.c:1033:13: warning: nested extern declaration of ’time’ [-Wnested-exte rns] src/tests.c:1040:5: warning: unknown conversion type character ’l’ in format [-W format=] printf(“random seed = %llu\n”, (unsigned long long)seed); ^ src/tests.c:1040:5: warning: too many arguments for format [-Wformat-extra-args] src/tests.c:1075:5: warning: unknown conversion type character ’l’ in format [-W format=] printf(“random run = %llu\n”, (unsigned long long)secp256k1_rand32() + ((un signed long long)secp256k1_rand32() « 32)); ^ src/tests.c:1075:5: warning: too many arguments for format [-Wformat-extra-args] CCLD tests.exe

  5. theuni commented at 7:13 pm on November 20, 2014: contributor

    @Bushstar Could you please try with bitcoin? The error looks link-order related. I have no idea what other coins are doing. If they’re not integrating the libsecp source directly, they’ll need to use pkg-config as usual to get dependencies sorted out.

    I’m inclined to believe this is not our bug.

  6. theuni commented at 7:16 pm on November 20, 2014: contributor
    @Bushstar I’d at least need to see the link-line to verify where the bug lies.
  7. theuni commented at 7:29 pm on November 20, 2014: contributor
    That’s not the link-line. Please use “make V=1”
  8. Bushstar commented at 9:40 pm on November 20, 2014: none

    Many thanks for stopping by. The full output from building secp256k1 with V=1 is linked in below. http://pastebin.com/mNpK0Etc

    Also the complete Qt pro file. http://pastebin.com/GKXKaJhw

  9. theuni commented at 4:15 am on November 21, 2014: contributor

    You’re not linking against libgmp. Please instruct your upstream to use proper dependency detection (pkg-config).

    I’ll be helpful in this case and give you the hard-coded simple (wrong) fix: change:

    0-l secp256k1
    

    to:

    0-lsecp256k1 -lgmp
    

    This is not our bug.

  10. Bushstar commented at 12:36 pm on November 21, 2014: none
    Thanks for taking a look into this, I did try linking -lgmp but linked it before secp256k1, fool on me. The client is now compiling. If you email me your Bitcoin address I will happily send you 0.1BTC as a small thank you. bushsolo (at) gmail.com
  11. Bushstar closed this on Nov 21, 2014

  12. Diapolo commented at 2:20 pm on November 26, 2014: none
    @theuni I can confirm that -lgmp needs to be after -lsecp256k1 in order to get it working in Windows :). Thanks for that great hint!
  13. theuni commented at 6:58 pm on December 8, 2014: contributor
    @Bushstar Thanks, but that’s not necessary. @Diapolo No problem. In general for the bfd/gold linkers, the link order should go from most dependent to least dependent.
  14. betachen cross-referenced this on Dec 15, 2017 from issue gmp.h:2097: undefined reference to `__gmpn_sub_n' by betachen

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 05:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me