g++ file.cpp -o file -l wolfssl:undefined reference to 'sp_init' collect2: error :ld returned 1 exit status

98 Views Asked by At
#include <iostream>
#include <string>
#include <unistd.h>
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/sp_int.h>
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/wolfmath.h>
using namespace std;
int main(){
    ecc_key key;
    WC_RNG rng;
    wc_ecc_init(&key);
    wc_InitGng(&rng);
    int curveId = ECC_SECP521R1;

    const ecc_set_type* ecc_params;
    ecc_params = wc_ecc_get_curve_params(curveId);

    mp_int ord;     //order of ecc
    mp_int priv;    //privatekey 
    int err;
    err = mp_init(&ord);
    cout<<err<<endl;
    err = mp_init(&priv);
    cout<<err<<endl;
    //err = mp_read_radix(&ord,ecc_params->order,MP_RADIX_HEX);   //
    //cout<<err<<endl;
    //err = wc_ecc_gen_k(&rng,120,&priv,&ord)
    return 0 ;
}


enter image description here

i have include <wolfssl/wolfcrypt/sp_int.h>,but it told me undefined reference to 'sp_init',one solution maybe work according tohttps://github.com/wolfSSL/wolfssl/pull/5328,but i don't quite understand .how to solve this problem

0

There are 0 best solutions below