libbitcoin / libbitcoin-system

Bitcoin Cross-Platform C++ Development Toolkit
https://libbitcoin.info/
Other
1.29k stars 382 forks source link

compile error: secp256k1_recovery.h: file not found #1163

Closed Bowfish closed 4 years ago

Bowfish commented 4 years ago

I followed the installation instructions and installed secp256k1 before. When running make I get the following error:

make: *** [Makefile:4179: src/math/libbitcoin_system_la-elliptic_curve.lo] Fehler 1
damian@xps:~/src/libbitcoin-system> make check
  CXX      src/math/libbitcoin_system_la-elliptic_curve.lo
src/math/elliptic_curve.cpp:24:10: schwerwiegender Fehler: secp256k1_recovery.h: Datei oder Verzeichnis nicht gefunden
   24 | #include <secp256k1_recovery.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
Kompilierung beendet.
make: *** [Makefile:4179: src/math/libbitcoin_system_la-elliptic_curve.lo] Fehler 1

It looks like there is a bug in the make install of secp256k1. I manually copied secp256k1_recovery.h to /usr/local/include and now it seems to works.

evoskuil commented 4 years ago

You need to build secp256k1 with the recovery option, see build instructions.

Bowfish commented 4 years ago

Ok. Thank you very much.

evoskuil commented 4 years ago

https://github.com/libbitcoin/libbitcoin-system/blob/master/README.md#autotools-advanced-users

Bowfish commented 4 years ago

Thank you very much. Now I get the following error:

  CXX      src/wallet/parse_encrypted_keys/libbitcoin_system_la-parse_encrypted_private.lo
  CXX      src/wallet/parse_encrypted_keys/libbitcoin_system_la-parse_encrypted_public.lo
  CXX      src/wallet/parse_encrypted_keys/libbitcoin_system_la-parse_encrypted_token.lo
  CXXLD    src/libbitcoin-system.la
copying selected object files to avoid basename conflicts...
  CXXLD    examples/libbitcoin-system-examples
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_parse'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_recover'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_signature_normalize'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_tweak_mul'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_create'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_serialize'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_nonce_function_rfc6979'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_signature_parse_der'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_signature_parse_compact'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_privkey_negate'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_context_create'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_signature_serialize_der'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_context_destroy'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_sign_recoverable'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_verify'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_negate'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_sign'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_privkey_tweak_mul'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_recoverable_signature_serialize_compact'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_combine'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ecdsa_recoverable_signature_parse_compact'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_privkey_tweak_add'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_pubkey_tweak_add'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin-system.so: undefined reference to `secp256k1_ec_seckey_verify'
collect2: error: ld returned 1 exit status
make: *** [Makefile:2846: examples/libbitcoin-system-examples] Fehler 1

Did I miss anything else?

evoskuil commented 4 years ago

Did you rebuild libsecp256k1? It’s missing (not linked).

Bowfish commented 4 years ago

Yes. It is installed in /usr/local/lib64:

total 17624
drwxr-xr-x 1 root root     416 Apr 13 20:50 ./
drwxr-xr-x 1 root root      40 Apr  9 12:29 ../
-rw-r--r-- 1 root root 9686358 Apr  9 16:48 libbitcoinconsensus.a
-rwxr-xr-x 1 root root    1011 Apr  9 16:48 libbitcoinconsensus.la*
lrwxrwxrwx 1 root root      28 Apr  9 16:48 libbitcoinconsensus.so -> libbitcoinconsensus.so.0.0.0*
lrwxrwxrwx 1 root root      28 Apr  9 16:48 libbitcoinconsensus.so.0 -> libbitcoinconsensus.so.0.0.0*
-rwxr-xr-x 1 root root 7339728 Apr  9 16:48 libbitcoinconsensus.so.0.0.0*
-rw-r--r-- 1 root root  437874 Apr 13 20:50 libsecp256k1.a
-rwxr-xr-x 1 root root     959 Apr 13 20:50 libsecp256k1.la*
lrwxrwxrwx 1 root root      21 Apr 13 20:50 libsecp256k1.so -> libsecp256k1.so.0.0.0*
lrwxrwxrwx 1 root root      21 Apr 13 20:50 libsecp256k1.so.0 -> libsecp256k1.so.0.0.0*
-rwxr-xr-x 1 root root  556088 Apr 13 20:50 libsecp256k1.so.0.0.0*
drwxr-xr-x 1 root root      74 Apr 13 20:50 pkgconfig/

Do I need to set it to LD_LIBRARY_PATH?

That is the output of make install of secp256k1


 /usr/bin/mkdir -p '/usr/local/lib64'
 /bin/sh ./libtool   --mode=install /usr/bin/install -c   libsecp256k1.la '/usr/local/lib64'
libtool: install: /usr/bin/install -c .libs/libsecp256k1.so.0.0.0 /usr/local/lib64/libsecp256k1.so.0.0.0
libtool: install: (cd /usr/local/lib64 && { ln -s -f libsecp256k1.so.0.0.0 libsecp256k1.so.0 || { rm -f libsecp256k1.so.0 && ln -s libsecp256k1.so.0.0.0 libsecp256k1.so.0; }; })
libtool: install: (cd /usr/local/lib64 && { ln -s -f libsecp256k1.so.0.0.0 libsecp256k1.so || { rm -f libsecp256k1.so && ln -s libsecp256k1.so.0.0.0 libsecp256k1.so; }; })
libtool: install: /usr/bin/install -c .libs/libsecp256k1.lai /usr/local/lib64/libsecp256k1.la
libtool: install: /usr/bin/install -c .libs/libsecp256k1.a /usr/local/lib64/libsecp256k1.a
libtool: install: chmod 644 /usr/local/lib64/libsecp256k1.a
libtool: install: /usr/bin/ranlib /usr/local/lib64/libsecp256k1.a
libtool: finish: PATH="/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib64
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /usr/bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 include/secp256k1.h include/secp256k1_preallocated.h include/secp256k1_recovery.h '/usr/local/include'
 /usr/bin/mkdir -p '/usr/local/lib64/pkgconfig'
 /usr/bin/install -c -m 644 libsecp256k1.pc '/usr/local/lib64/pkgconfig'
evoskuil commented 4 years ago

The linker isn’t looking there. If you use the Libbitcoin install.sh to build both it will be set up correctly.

Bowfish commented 4 years ago

I installed secp256k1 with:

$ ./autogen.sh
$ ./configure --enable-module-recovery
$ make
$ make check
$ sudo make install

and libbitcoin-system with

$ ./autogen.sh
$ ./configure
$ make
evoskuil commented 4 years ago

That’s called the advanced install for a reason. Notice there’s a lot going on in install.sh.

Bowfish commented 4 years ago

Now I tried to install it with:

$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
$ ./install.sh --prefix=/home/src/libbitcoin --build-boost --disable-shared

Now I get this errors:

  CXXLD    src/libbitcoin.la
copying selected object files to avoid basename conflicts...
  CXXLD    examples/libbitcoin-examples
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin.a(libbitcoin_la-elliptic_curve.o): in function `libbitcoin::verify_signature(secp256k1_context_struct const*, secp256k1_pubkey, std::array<unsigned char, 32ul> const&, std::array<unsigned char, 64ul> const&)':
/tmp/build-libbitcoin/libbitcoin/src/math/elliptic_curve.cpp:118: undefined reference to `secp256k1_ecdsa_signature_normalize'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/build-libbitcoin/libbitcoin/src/math/elliptic_curve.cpp:119: undefined reference to `secp256k1_ecdsa_verify'
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: src/.libs/libbitcoin.a(libbitcoin_la-elliptic_curve.o): in function `bool libbitcoin::parse<33ul>(secp256k1_context_struct const*, secp256k1_pubkey&, std::array<unsigned char, 33ul> const&)':
/tmp/build-libbitcoin/libbitcoin/src/math/elliptic_curve.cpp:51: undefined reference to `secp256k1_ec_pubkey_parse'
.
.
.
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: /tmp/build-libbitcoin/libbitcoin/src/math/external/lax_der_parsing.c:142: undefined reference to `secp256k1_ecdsa_signature_parse_compact'
collect2: error: ld returned 1 exit status
make: *** [Makefile:2418: examples/libbitcoin-examples] Fehler 1

real    2m10.894s
user    11m59.692s
sys     0m52.218s
evoskuil commented 4 years ago

You need to include the option to build libsecp256k1.

Bowfish commented 4 years ago

Which of the options do I have to include?

# Script options:
# --with-icu               Compile with International Components for Unicode.
#                            Since the addition of BIP-39 and later BIP-38
#                            support, libbitcoin conditionally incorporates ICU
#                             to provide BIP-38 and BIP-39 passphrase
#                            normalization features. Currently
#                            libbitcoin-explorer is the only other library that
#                            accesses this feature, so if you do not intend to
#                            use passphrase normalization this dependency can
#                            be avoided.
# --with-png               Compile with QR Code PNG Output Support
#                            Since the addition of png support, libbitcoin
#                            conditionally incorporates libpng (which in turn
#                            requires zlib). Currently libbitcoin-explorer is
#                            the only other library that accesses this feature,
#                            so if you do not intend to use png this dependency
#                            can be avoided.
# --with-qrencode          Compile with QR Code Support
#                            Since the addition of qrcode support, libbitcoin
#                            conditionally incorporates qrencode. Currently
#                            libbitcoin-explorer is the only other library that
#                            accesses this feature, so if you do not intend to
#                            use qrcode this dependency can be avoided.
# --build-icu              Builds ICU libraries.
# --build-zlib             Builds ZLib libraries.
# --build-png              Builds PNG libraries.
# --build-qrencode         Builds QREncode libraries.
# --build-boost            Builds Boost libraries.
# --build-dir=<path>       Location of downloaded and intermediate files.
# --prefix=<absolute-path> Library install location (defaults to /usr/local).
# --disable-shared         Disables shared library builds.
# --disable-static         Disables static library builds.
# --help                   Display usage, overriding script execution

I tried it with:

$ ./install.sh --prefix=/home/src/libbitcoin --build-boost --disable-shared --enable-module-recovery

But I got the same errors.

Bowfish commented 4 years ago

I run ./install.sh without the --prefix option. The library compiled without any errors, but the libbitcoin-test_runner.sh test failed. Here is the output:

FAIL: libbitcoin-test_runner.sh
========================================
   libbitcoin 3.6.0: ./test-suite.log
========================================

# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: libbitcoin-test_runner.sh
===============================

FAIL libbitcoin-test_runner.sh (exit status: 201)

============================================================================
Testsuite summary for libbitcoin 3.6.0
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to eric@voskuil.org
============================================================================
make[2]: *** [Makefile:6031: test-suite.log] Fehler 1
make[2]: Verzeichnis „/tmp/build-libbitcoin/libbitcoin“ wird verlassen
make[1]: *** [Makefile:6139: check-TESTS] Fehler 2
make[1]: Verzeichnis „/tmp/build-libbitcoin/libbitcoin“ wird verlassen
make: *** [Makefile:6346: check-am] Fehler 2
Running 1901 test cases...
Platform: linux
Compiler: GNU C++ version 9.2.1 20200306 [revision c5edde44f5b17b4891f17a63517f355bbf89e7d3]
STL     : GNU libstdc++ version 20200306
Boost   : 1.71.0
test/chain/block.cpp(71): fatal error: in "chain_block_tests/block__locator_size__positive_backoff__returns_log_plus_eleven": critical check 18u == chain::block::locator_size(top) has failed [18 != 19]

real    7m30.217s
user    50m4.038s
sys     2m45.889s
evoskuil commented 4 years ago

Known issue, not a bug, you can ignore.

Bowfish commented 4 years ago

Ok. Thank you very much for your help. Now I can deep dive into libbitcoin.