bitcoindevkit/bdk-kotlin

Failing to build

caiofaustino opened this issue · 3 comments

Hi there, I'm trying to build the project myself but I'm facing an issue.

First I updated uniffi in my Cargo.toml on the bdk-ffi submodule file to match the version installed in my CLI

[dependencies]
bdk = { version = "0.13", features = ["all-keys", "use-esplora-ureq"] }
uniffi_macros = "0.16.0"
uniffi = "0.16.0"
thiserror = "1.0"
anyhow = "=1.0.45" # remove after upgrading to next version of uniffi

[build-dependencies]
uniffi_build = "0.16.0"

Bu now I'm seeing this issue with ring dependency. I'm using NDK version 23.1.7779620

This is the console output I have

Build and test bdk-ffi library for local platform (darwin or linux)
~/workspace/bitcoin/bitcoindevkit/bdk-kotlin/bdk-ffi ~/workspace/bitcoin/bitcoindevkit/bdk-kotlin
    Finished release [optimized] target(s) in 0.03s
    Finished test [unoptimized + debuginfo] target(s) in 0.03s
     Running unittests (target/debug/deps/bdkffi-6bf461246c56dc6e)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Copy linux libs to jvm subproject
Generate kotlin bindings from bdk.udl to jvm subproject
aarch64,x86_64,i686
   Compiling ring v0.16.20
   Compiling secp256k1-sys v0.4.1
   Compiling semver-parser v0.10.2
   Compiling anyhow v1.0.45
   Compiling parking_lot_core v0.8.5
   Compiling getrandom v0.1.16
   Compiling socks v0.3.3
   Compiling crossbeam-utils v0.8.5
error: failed to run custom build command for `ring v0.16.20`

Caused by:
  process didn't exit successfully: `/home/caiof/workspace/bitcoin/bitcoindevkit/bdk-kotlin/bdk-ffi/target/release/build/ring-a763e9a8b7d8c1bd/build-script-build` (exit status: 101)
  --- stdout
  OPT_LEVEL = Some("3")
  TARGET = Some("aarch64-linux-android")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_aarch64-linux-android = None
  CC_aarch64_linux_android = None
  TARGET_CC = None
  CC = Some("aarch64-linux-android21-clang")
  CFLAGS_aarch64-linux-android = None
  CFLAGS_aarch64_linux_android = None
  TARGET_CFLAGS = None
  CFLAGS = Some("-D__ANDROID_API__=21")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")

  --- stderr
  running "aarch64-linux-android21-clang" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-D__ANDROID_API__=21" "-I" "include" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/home/caiof/workspace/bitcoin/bitcoindevkit/bdk-kotlin/bdk-ffi/target/aarch64-linux-android/release/build/ring-84f67e3140f20a93/out/aesv8-armx-linux64.o" "/home/caiof/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/pregenerated/aesv8-armx-linux64.S"
  <built-in>:368:9: error: '__ANDROID_API__' macro redefined [-Werror,-Wmacro-redefined]
  #define __ANDROID_API__ 21
          ^
  <built-in>:360:9: note: previous definition is here
  #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
          ^
  1 error generated.
  thread 'main' panicked at 'execution failed', /home/caiof/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/build.rs:656:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

warning: In file included from <built-in>:365:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:359:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: 1 warning generated.
warning: In file included from <built-in>:365:
warning: <command line>:2:9: warning: '__ANDROID_API__' macro redefined [-Wmacro-redefined]
warning: #define __ANDROID_API__ 21
warning:         ^
warning: <built-in>:359:9: note: previous definition is here
warning: #define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
warning:         ^
warning: depend/secp256k1/src/secp256k1.c:7:9: warning: 'SECP256K1_BUILD' macro redefined [-Wmacro-redefined]
warning: #define SECP256K1_BUILD
warning:         ^
warning: <command line>:3:9: note: previous definition is here
warning: #define SECP256K1_BUILD 1
warning:         ^
warning: 2 warnings generated.

error: build failed

Try setting your ANDROID_NDK_HOME to a 21.x version of the android SDK, see README notes here:
https://github.com/bitcoindevkit/bdk-kotlin#how-to-build

@caiofaustino are you still running into this issue?

Sorry, I didn't have time to test this before and ended up forgetting about it.
Build successful now! Thanks a lot!

(in my defense, the comment on the readme want´t there yet when I tried this. 😅 )