1

I'm trying to compile this code written in C:

#include <stdio.h>
#include <stdlib.h>
#include <C:\OpenSSL-Win32\include\openssl\sha.h>
#include <string.h>

main() {
char data[] = "Hello, world!";
size_t length = strlen(data);

unsigned char hash[SHA_DIGEST_LENGTH];
SHA1(data, length, hash);
}

I'm using Dev-C++. It gives me the error : undefined reference to `SHA1'. I founded this post: Undefined reference to `SHA1' but I didn't solve the problem. Can anyone help me?

MrCaptain Alex
  • 169
  • 1
  • 13

1 Answers1

2

MrCaptain Alex, Rup and Barmar wrote what is the correct way, but in my case, I have Ubuntu, when I link, It's necesary add the library -L/usr/lib -lcrypto:

$ gcc -o executable_file source_file.c -L/usr/lib -lcrypto

That's all ;-)

James Brown
  • 36,089
  • 7
  • 43
  • 59
steels
  • 21
  • 3