What to do if a compile error occurs when you try to calculate sha1 in C language of OSX

I got a compile error when I tried to calculate sha1 using #include <openssl / sha.h>.

Undefined symbols for architecture x86_64:
  "_SHA1_Final", referenced from:
      _calc_sha1 in sha1-8b90d3.o
  "_SHA1_Init", referenced from:
      _calc_sha1 in sha1-8b90d3.o
  "_SHA1_Update", referenced from:
      _calc_sha1 in sha1-8b90d3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

approach

I solved it by specifying -lcrypto when compiling.

gcc -lssl -lcrypto sha1.c

(On Linux, I feel like I could just use -lssl, but why ...)

Recommended Posts