Topic: 'undefined reference'

Hi,

I have run into following error:
/tmp/ccrfx1RK.o: In function `main':
sha.c:(.text+0x3d): undefined reference to `wc_InitSha'
sha.c:(.text+0x58): undefined reference to `wc_ShaUpdate'
sha.c:(.text+0x6e): undefined reference to `wc_ShaFinal'
collect2: error: ld returned 1 exit status

The code I am trying to compile is as follows:

#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/sha.h>

int main()
{
  int ret = 0;
  char hash[20];

  char string[8] = "Test sha";

  Sha sha[1];
  wc_InitSha(sha);
  wc_ShaUpdate(sha, string, 8);
  wc_ShaFinal(sha, hash);

}


I have installed wolfSSL per instruction for Linux and the tests ran fine.
I would appreciate any help to get over this blocker.

Share

Re: 'undefined reference'

Hi swaroopk,

Did you install your distro's wolfSSL, or did you build it yourself?  If you built it yourself, please attach your build settings (user_settings.h or ./configure line).
It looks like you're missing SHA support (ie. --disable-sha or NO_SHA), please confirm SHA is enabled.  Please also confirm you're using the latest wolfSSL release, 5.5.3.

Share

Re: 'undefined reference'

Hi kareem_wolfssl,

I have latest release from GitHub. I built it with default ./configure i.e. without any options.

I believe SHA is enabled, I see following configure status when I build:

   * SHA:                        yes
   * SHA-224:                  yes
   * SHA-384:                  yes
   * SHA-512:                  yes
   * SHA3:                       yes

Share

Re: 'undefined reference'

It works now.

I had not specified the library as -lwolfssl while compiling my code using gcc!

Share