无法使用 secp256k1 库进行编译

Failed to compile with secp256k1 library

所以我在学习这个教程:https://nickfarrow.com/Cryptography-in-Bitcoin-with-C/ I installed libsecp256k1 from 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

提前致谢!

尝试:

gcc prvkey.c -o exec -lcrypto -lsecp256k1

gcc -l 与库文件的链接。

如果有任何问题请告诉我。