Topic: undefined reference to wolfSSL_SHA256_Init

I'm trying to build a very basic application to generate a SHA256 hash from a string. Works no problem with openssl lib but with wolfssl I get the following:

test.c:(.text+0x28): undefined reference to wolfSSL_SHA256_Init'
test.c:(.text+0x48): undefined reference towolfSSL_SHA256_Update'
test.c:(.text+0x5d): undefined reference to `wolfSSL_SHA256_Final'

I'm compiling using gcc on ubuntu with the following:
gcc test.c -lm -lwolfssl

wolfssl lib compiled and installed no problems on my system, i'm using 3.6.0.

With openssl lib I use:
gcc test.c -lm -lcrypto
compiles no problem.

Am I missing something? I'm new to C, any help would be greatly appreciated.

Share

Re: undefined reference to wolfSSL_SHA256_Init

Hi Gareth,

The wolfSSL_SHA256_Init(), wolfSSL_SHA256_Update(), and wolfSSL_SHA256_Final() functions are part of the wolfSSL OpenSSL Compatibility layer.  Are you enabling that layer at compile time when you are building wolfSSL?  You can do that when using ./configure with "--enable-opensslextra", or if using preprocessor flags by defining OPENSSL_EXTRA.

If you don't want to use the OpenSSL Compatibility Layer, you can use our wolfCrypt SHA-256 functionality directly through the following header file:

<wolfssl/wolfcrypt/sha256.h>

Specifically the following functions:

int wc_InitSha256(Sha256* sha);
int wc_Sha256Update(Sha256* sha, const byte* data, word32 len);
int wc_Sha256Final(Sha256* sha, byte* out);

Best Regards,
Chris