0

I'm currently working on a web server in C and I wanted to include for hashing passwords. My problem right now is that I get the error undefined reference to 'SHA1' when trying to compile. It appears to be an error with the Linker because the building seemed to work fine.

This is how I call SHA1():

SHA1(src, srcLength, hashStr);

I've simply installed OpenSSL by using apt-get install openssl

Do I somehow have to add OpenSSL to the target_link_libraries in the CMake-File?

EDIT: Sorry, I miss-typed, I installed openssl-dev, not just openssl

Matze
  • 5,100
  • 6
  • 46
  • 69
Halsi
  • 53
  • 1
  • 2
  • 9
  • Possible duplicate of [Include OpenSSL in a CMakeList.txt file](https://stackoverflow.com/questions/45548088/include-openssl-in-a-cmakelist-txt-file) – Leśny Rumcajs May 30 '19 at 17:40

1 Answers1

0

You need to install the development package sudo apt-get install libssl-dev which includes the necessary header files.

  • Sorry, I accidentally typed openssl not openssl-dev here, I've already installed that – Halsi May 30 '19 at 09:43
  • @Halsi well you also need `find_package(OpenSSL)` and add `${OPENSSL_INCLUDE_DIRS}` to your include dirs. And link the target library. –  May 30 '19 at 09:46