Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmp.h:2097: undefined reference to `__gmpn_sub_n' #209

Closed
betachen opened this issue Dec 15, 2017 · 3 comments
Closed

gmp.h:2097: undefined reference to `__gmpn_sub_n' #209

betachen opened this issue Dec 15, 2017 · 3 comments

Comments

@betachen
Copy link
Member

Link error for mvsd on some OS:

/usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_mod_inverse': /home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:128: undefined reference to __gmpn_gcdext'
/usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function __gmpn_sub': /usr/include/x86_64-linux-gnu/gmp.h:2097: undefined reference to __gmpn_sub_n'
/usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_set_bin': /home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:49: undefined reference to __gmpn_set_str'
/home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:49: undefined reference to __gmpn_set_str' /usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_get_bin':
/home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:34: undefined reference to __gmpn_get_str' /usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_set_bin':
/home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:49: undefined reference to __gmpn_set_str' /home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:49: undefined reference to __gmpn_set_str'
/usr/local/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function secp256k1_num_get_bin': /home/travis/build/mvs-org/metaverse/build-mvs-dependencies/secp256k1/src/num_gmp_impl.h:34: undefined reference to __gmpn_get_str'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/mvsd] Error 1
make[2]: Leaving directory `/home/travis/build/mvs-org/metaverse/build'

make[1]: *** [src/mvsd/CMakeFiles/mvsd.dir/all] Error 2
make[1]: Leaving directory `/home/travis/build/mvs-org/metaverse/build'
make: *** [all] Error 2

Refers to bitcoin issues:
bitcoin-core/secp256k1#111
bitcoin-core/secp256k1#430

how to resolves:
secp256k1

./configure --with-bignum=no
vorapoap added a commit to vorapoap/metaverse that referenced this issue Apr 10, 2018
@robby-d
Copy link

robby-d commented Aug 15, 2018

Ran into this same issue on Ubuntu 18.04LTS. Fix is adding -lgmp to the end of the command in src/mvsd/CMakeFiles/mvsd.dir/link.txt and src/mvs-cli/CMakeFiles/mvs-cli.dir/link.txt (i.e. it should appear as the very last thing, as if it is before libsec256k1 linking will still fail)

@luozhaohui
Copy link
Contributor

@robby-dermody Thank you.

@viertelb
Copy link

I have the exact same error when compiling a small code which includes bitcoin.hpp with g++ -o addr 69_addr2.cpp $(pkg-config --cflags --libs libbitcoin). On my Raspberry, I have /usr/include/arm-linux-gnueabihf/gmp.h. Since I am an absolut noob I wanted to ask where I need to put -lgmp in my case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants