所以我一直在关注本教程:https ://nickfarrow.com/Cryptography-in-Bitcoin-with-C/我libsecp256k1
从https://www.howtoinstall.me/ubuntu/18-04/libsecp256k1-dev/安装但同时编译我的程序:
#include <secp256k1.h>
#include <stdio.h>
static secp256k1_context *ctx = NULL;
int main()
{
ctx = secp256k1_context_create(
SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
/* Declare the private variable as a 32 byte unsigned char */
unsigned char seckey[32];
/* Load private key (seckey) from random bytes */
FILE *frand = fopen("/dev/urandom", "r");
/* Read 32 bytes from frand */
fread(seckey, 32, 1, frand);
/* Close the file */
fclose(frand);
/* Loop through and print each byte of the private key, */
printf("Private Key: ");
for (int i = 0; i < 32; i++)
{
printf("%02X", seckey[i]);
}
printf("\n");
}
我得到:
josh@pc:~/Code$ gcc prvkey.c -o exec
/tmp/cc5OVPMJ.o: In function `main':
prvkey.c:(.text+0x1d): undefined reference to `secp256k1_context_create'
collect2: error: ld returned 1 exit status
提前致谢!