简体   繁体   中英

Ruby FFI not finding certain functions?

I'm trying to use Ruby's FFI library to link functions from the bitcoin-core secp256k1 library .

To make the secp256k1_ecdsa_sign function accessible, I built libsecp256k1 using autotools (as directed in README.md ). Then I created a shared object to use in FFI by running g++ -shared secp256k1/src/.libs/libsecp256k1_la-secp256k1.o . Importing this into my Ruby file using FFI let me use the function and everything worked perfectly.

I'm trying to do the exact same with the secp256k1_ecdsa_sign_recoverable function, which is in the same C project, just a different header file. However, I get the error Function 'secp256k1_ecdsa_sign_recoverable' not found in [bin/secp256k1.so] (FFI::NotFoundError) .

I think this is either because I'm not creating the shared object properly (created with the aforementioned g++ command), or because this function is for some reason not a public-facing one in the C project (though I don't know enough about C to know how to figure out if this is the case).

If someone could help me figure out how to use this function it would be greatly appreciated.

It ends up the secp256k1_recovery.h file is only included if you specify that when building the libsecp256k1 library. Specifically, I needed to run ./configure --enable-module-recovery instead of ./configure .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM