title: How to generate SHA3 with openssl 1.1.1a
body: <p>Edit: I extracted the SHA3 code from this question(<a href="https://stackoverflow.com/questions/51144505/generate-sha-3-hash-in-c-using-openssl-library">Generate SHA-3 hash in C++ using OpenSSL library</a>) and SHA3 is in the openssl 1.0.2q(but not 1.0.2r) version.</p>
  
  <p>I am trying to generate SHA3 with the openssl library. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;openssl/evp.h&gt;
  unsigned int SHALEN=32;
  void sha3(unsigned char *digest, const unsigned char *message, size_t message_len)
  {
      EVP_MD_CTX *mdctx;
      mdctx = EVP_MD_CTX_create();
      EVP_DigestInit_ex(mdctx, EVP_sha3_256(), NULL);
      EVP_DigestUpdate(mdctx, message, message_len);
      EVP_DigestFinal_ex(mdctx, digest, &amp;SHALEN);
      EVP_MD_CTX_destroy(mdctx);
  }
  int main()
  {
      unsigned char digest[32];
      unsigned char message[32];
      for(int i=0;i&lt;32;i++)
          message[i]=0;
      sha3(digest,message,32);
  }
  </code></pre>
  
  <p>The above code works on my personal Mac (with openssl 1.0.2q 2018Nov) but not on the server(Ubuntu 16.04, openssl version=1.1.1a). When compiled with </p>
  
  <pre><code>  g++ test.cpp -lcrypto 
  </code></pre>
  
  <p>It gives</p>
  
  <pre><code>/tmp/ccXTFrzC.o: In function `sha3(unsigned char*, unsigned char const*, unsigned long)':
  test.cpp:(.text+0x1e): undefined reference to `EVP_sha3_256'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I looked up the openssl manual but it is not very helpful. Is there anything I missed here? Thanks in advance.</p>
  
  <p>BTW, I am advised not to downgrade openssl to solve the problem.</p>