How to compile Secp256K1 .a static library for different architectures #1109
issue BatterMan-Li openend this issue on May 28, 2022-
BatterMan-Li commented at 12:33 pm on May 28, 2022: noneAt 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
-
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
-
pjalocha commented at 11:00 pm on November 18, 2022: noneAny 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 ?
-
real-or-random commented at 11:02 pm on November 18, 2022: contributorIf 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. -
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.
-
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. -
bitcoin-core locked this on Jan 30, 2023
-
converted_to_discussion real-or-random
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
More mirrored repositories can be found on mirror.b10c.me