How to compile Secp256K1 .a static library for different architectures #1109

issue BatterMan-Li openend this issue on May 28, 2022
  1. BatterMan-Li commented at 12:33 pm on May 28, 2022: none
    At present, my project depends on the secp256k1 library file. Now I need to compile the static library of different architectures for the Android JNI interface. How should I compile it? Please help me, thank you very much
  2. real-or-random commented at 3:00 pm on May 29, 2022: contributor

    Set your PATH correctly, for instance:

    0export PATH="$PATH:/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
    

    For ARM32 with experimental assembler::

    0./configure --enable-experimental --with-asm=arm --host=arm-linux-androideabi CC=armv7a-linux-androideabi21-clang CFLAGS="-mthumb -march=armv7-a" CCASFLAGS="-Wa,-mthumb -Wa,-march=armv7-a"
    

    For other architectures, a simpler config should work, for instance:

    0./configure --host=aarch64-linux-androideabi CC=aarch64-linux-android31-clang
    

    You’ll find the .a file in .libs.

    Note that there will be many different compilers with different JNI version numbers. You need to select the one you need. 21 and 31 are arbitrary choices above.

    related: https://github.com/bitcoin-core/secp256k1/issues/621

  3. pjalocha commented at 11:00 pm on November 18, 2022: none
    Any dea how to use the library for Arduino/PlatformIO projects ? I need it for HELTEC CubeCell under PlatformIO and Arduio - it starts compiling, but then arm-eabi-none-as is called on the .s files and it wants (I guess a PlatformIO bug) -Os options which fails. Possibly a pure C-version would solve the problem ?
  4. real-or-random commented at 11:02 pm on November 18, 2022: contributor
    If it’s using the ARM assembly and you want pure C, you can force that with ./configure --with-asm=no. But please post the actual output of the tools, that will help.
  5. pjalocha commented at 12:34 pm on November 19, 2022: none

    Thank you, I suspect PlanformIO would not understand any of it because it take the library from the github as it is thus I have no chance to do any configuration.

    I tried to copy just the .c file and compile - it did, but then it would not link, I guess not enough flash on my device, so for now I gave up on this and found uECC library which does compile and link. I will see how long it takes to sign. Another problem there is to create recoverable signature but I should be able to work this out.

    I will use your library on the receiving end, but there is compiles already, so all is fine.

  6. real-or-random commented at 11:57 am on November 21, 2022: contributor

    I tried to copy just the .c file and compile - it did, but then it would not link, I guess not enough flash on my device,

    you can ./configure --with-ecmult-window=4 --with-ecmult-gen-precision=2.

    Thank you, I suspect PlanformIO would not understand any of it because it take the library from the github as it is thus I have no chance to do any configuration.

    Well I don’t know how PlanformIO works but if it targets embedded then maybe its package should set these by default? But I can’t find the package here: https://registry.platformio.org/search Which package are you using? Maybe you want to create an official package?

    If you can set defines/compiler options, then -DECMULT_WINDOW_SIZE=4 -DECMULT_GEN_PREC_BITS=2 should have the same effect.

  7. bitcoin-core locked this on Jan 30, 2023
  8. ?
    converted_to_discussion real-or-random

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-11-22 06:15 UTC

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