Reputation: 53
I am trying to use CPR in android. This is my src/main/cpp
directory's structure:
cpr/
native-lib.cpp
CMakeLists.txt
note: cpr/ directory is generated by running this command git clone --recurse-submodules https://github.com/whoshuu/cpr.git
And this is the content of CMakeLists.txt
in src/main/cpp
directory:
cmake_minimum_required(VERSION 3.4.1)
add_library(
native-lib
SHARED
native-lib.cpp
)
find_library(
log-lib
log
)
add_subdirectory(cpr)
target_link_libraries(
native-lib
cpr
${log-lib}
)
But I get this error when I build and run the code:
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR)
Upvotes: 0
Views: 416
Reputation: 48
You can first look at this stack-overflow
answer: Visit reference - find open-ssl.
If you're on Linux-OS - this worked!. You can install open-ssl
via terminal as:
sudo apt-get install libssl-dev
Otherwise, you have to solved as follows: You have to open the CMakeCache.txt
file in source-directory
, find the line:
- OPENSSL_INCLUDE_DIR:PATH=OPENSSL_INCLUDE_DIR-NOTFOUND
Visit reference: find-open-ssl, then change it to with your openssl location inside source-directory as follows:
- OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include
For further learing in detail: Visit reference- open-ssl-during-cmake
Upvotes: 2