Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

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

Closed
BatterMan-Li opened this issue May 28, 2022 · 5 comments
Closed

Comments

@BatterMan-Li
Copy link

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

@real-or-random
Copy link
Contributor

real-or-random commented May 29, 2022

Set your PATH correctly, for instance:

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

For ARM32 with experimental assembler::

./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:

./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: #621

@pjalocha
Copy link

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 ?

@real-or-random
Copy link
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.

@pjalocha
Copy link

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
Copy link
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 bitcoin-core locked and limited conversation to collaborators Jan 30, 2023
@real-or-random real-or-random converted this issue into discussion #1202 Jan 30, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@real-or-random @pjalocha @BatterMan-Li and others