Author

Topic: Using native sipa's secp256k1 shared library in Java's bitcoinj? (Read 2566 times)

newbie
Activity: 3
Merit: 0
Thank you very much for the suggestions. Unfortunately after converting the archive to a shared library and trying to load it, I'm seeing the same unresolved symbol errors for gmp_sub_n. Here's a question - after running the configure and make commands, am I supposed to be using the libtool to install the library somehow so my Java program can pick it up automatically?
hero member
Activity: 518
Merit: 500
r00t-dev
I have been trying for almost a day to compile the sipa library here: https://github.com/bitcoin/secp256k1 to no avail. There are some instructions in the bitcoinj client that says:

To build secp256k1 for use with bitcoinj, run `./configure` and `make libjavasecp256k1.so` then copy libjavasecp256k1.so to your system library path or point the JVM to the folder containing it with -Djava.library.path



However there doesn't seem to be a make target for that anymore with the master release on github. I compiled it anyway, and it creates a static library. Is there a way to turn that into a shared object library for a java application?

As a last resort I tried to compile an older version and even managed to create the file libjavasecp256k1.so, but any attempts to load it let to UnsatisfiedLinkErrors that said: unresolved symbol: __gmpn_sub_n or others. It seems like there are missing references to the gmp library.

This is really not my forte so I would appreciate any advice on how to get this working.

afaik static libs are AR-archives. convert them into a
shared lib and call that lib with the java native interface:

Code:
ar -x libsecp256k1.a     //extract archive
gcc -shared *.o -o libsecp256k1.so     //generate shared lib


sources:
http://www.linuxquestions.org/questions/linux-software-2/convert-static-library-filename-a-to-dynamic-shared-object-filename-so-465709/#post2861823
http://jonisalonen.com/2012/calling-c-from-java-is-easy/



p.s. i recommend you to use Bounty Castles custom secp256k1 implementation.
it was also implemented into bitcoinj because of it s runtime improvement.

read:
https://code.google.com/p/bitcoinj/issues/detail?id=509




newbie
Activity: 3
Merit: 0
I have been trying for almost a day to compile the sipa library here: https://github.com/bitcoin/secp256k1 to no avail. There are some instructions in the bitcoinj client that says:

To build secp256k1 for use with bitcoinj, run `./configure` and `make libjavasecp256k1.so` then copy libjavasecp256k1.so to your system library path or point the JVM to the folder containing it with -Djava.library.path



However there doesn't seem to be a make target for that anymore with the master release on github. I compiled it anyway, and it creates a static library. Is there a way to turn that into a shared object library for a java application?

As a last resort I tried to compile an older version and even managed to create the file libjavasecp256k1.so, but any attempts to load it let to UnsatisfiedLinkErrors that said: unresolved symbol: __gmpn_sub_n or others. It seems like there are missing references to the gmp library.

This is really not my forte so I would appreciate any advice on how to get this working.
Jump to: