Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while compiling code in android #7

Open
sadeghhosseini opened this issue Oct 31, 2019 · 2 comments
Open

Error while compiling code in android #7

sadeghhosseini opened this issue Oct 31, 2019 · 2 comments

Comments

@sadeghhosseini
Copy link

sadeghhosseini commented Oct 31, 2019

I am trying to build and use this library in android.
This is my cp/CMakeLists.txt's content:

cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
        native-lib

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp)

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)





file(GLOB_RECURSE OPENSSL_SOURCES "openssl/*.c")
include_directories(openssl/include)
add_library(openssl SHARED ${OPENSSL_SOURCES})



target_link_libraries( # Specifies the target library.
        native-lib
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

When I try to build this, I get this error:
C:/Users/admin/AndroidStudioProjects/CPR/app/src/main/cpp/openssl/crypto/bn/bn_depr.c:15:10: fatal error: 'openssl/opensslconf.h' file not found

What is the problem?
Thanks in advance.

@janbar
Copy link
Owner

janbar commented Oct 31, 2019

You have to use the cmake project provided with it by the following:
I.e if you have copied this project into your source dir (CMAKE_CURRENT_SOURCE_DIR) with the path name "openssl":

# Provides dependency openssl
find_package(OpenSSL QUIET)
if(NOT OPENSSL_FOUND)
    add_subdirectory(
        ${CMAKE_CURRENT_SOURCE_DIR}/openssl
        ${CMAKE_CURRENT_BINARY_DIR}/openssl
        EXCLUDE_FROM_ALL
    )
    set(OPENSSL_SSL_LIBRARY ssl)
    set(OPENSSL_CRYPTO_LIBRARY crypto)
    set(OPENSSL_INCLUDE_DIR "${openssl_BINARY_DIR}/include" "${openssl_BINARY_DIR}")
    set(OPENSSL_FOUND ON)
    message(STATUS "Build OpenSSL: ${openssl_BINARY_DIR}")
endif()

set (HAVE_OPENSSL 1)
include_directories (${OPENSSL_INCLUDE_DIR})
...
target_link_libraries (native-lib  ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})

@peerless2012
Copy link

I build success for android with the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants