0

I am creating an encryption library in android studio by android NDK. I am using CMakeLists.txt script.

In the C++ file, I want to include #include <openssl/sha.h>.

How can I include OpenSSL in my c++ file?

jww
  • 97,681
  • 90
  • 411
  • 885
Mayank Jindal
  • 355
  • 5
  • 15
  • Also see [EVP Message Digests](https://wiki.openssl.org/index.php/EVP_Message_Digests) on the OpenSSL wiki. [EVP Symmetric Encryption and Decryption | C++ Programs](https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption#C.2B.2B_Programs) offers some hints when using OpenSSL and C++. – jww Jun 27 '17 at 03:26

1 Answers1

0

What you need is to have in CMakeLists.txt a line like

INCLUDE_DIRECTORIES(SYSTEM "/path/to/openssl")

then in the C++ source file you simply

#include <sha.h> // or #include <openssl/sha.h>
vsoftco
  • 55,410
  • 12
  • 139
  • 252
  • include_directories(src/main/cpp/openssl/). It is giving `undefined reference to ...` for every function error. – Mayank Jindal Jun 27 '17 at 03:36
  • @MAYANKJINDAL That's a linker error. Make sure you link the openssl library with your project. See e.g. [this](https://stackoverflow.com/questions/24570916/add-external-libraries-to-cmakelist-txt-c) for how to add target link library. – vsoftco Jun 27 '17 at 04:19