Home > Mobile >  Error when building POCO for Android with NETSSL support
Error when building POCO for Android with NETSSL support

Time:09-21

I'm trying to build POCO for Android (x86) with NetSSL_OpenSSL support which is not enabled by default. This is my configure line:

$ ./configure --config=Android

And this is my cmake line:

$ cmake -H. -B./poco-build-x86 -G'Ninja' -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/Users/me/Library/Android/android-ndk-r19c/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_ABI=x86 -DCMAKE_INSTALL_PREFIX:PATH=install-x86  -DOPENSSL_ROOT_DIR=/Users/me/dev/openssl-1.1.1g/install-x86/ -DOPENSSL_CRYPTO_LIBRARY=/Users/me/dev/openssl-1.1.1g/install-x86/lib -DOPENSSL_INCLUDE_DIR=/Users/me/dev/openssl-1.1.1g/install-x86 -DENABLE_CRYPTO=ON -DENABLE_NETSSL=ON

I'm getting this error at cmake time:

-- Checking for C  14 compiler
-- Checking for C  14 compiler - available
-- Could NOT find APR (missing: APR_INCLUDE_DIR APR_LIBRARY)
-- Could NOT find APRUTIL (missing: APRUTIL_INCLUDE_DIR APRUTIL_LIBRARY)
-- Could NOT find Apache2 (missing: APACHE2_INCLUDE_DIR)
-- Could NOT find MYSQL (missing: MYSQL_INCLUDE_DIR MYSQL_LIBRARY)
-- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR)
-- Could NOT find ODBC (missing: ODBC_LIBRARY ODBC_INCLUDE_DIR)
-- Building without tests & samples
-- Using internal sqlite, zlib, pcre, expat, ...
-- SQLite Support Enabled
-- MySQL Support Disabled
-- PostgreSQL Support Disabled
-- ODBC Support Disabled
-- CMake 3.10.2 successfully configured Poco using Ninja generator
-- Poco package version: 1.10.1
-- Building dynamic libraries
-- [cmake] Installation target path: install-x86
-- [cmake] Use toolchain file:      /Users/juangarcia/Library/Android/android-ndk-r19c/build/cmake/android.toolchain.cmake
-- [cmake] Bulid for OS type:       Android
-- [cmake] Build for OS version:    1
-- [cmake] Build for CPU type:      i686
-- [cmake] Build type:              Release
-- [cmake] Build with cxx flags:    -O2 -DNDEBUG  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc  
-- [cmake] Build with c flags:      -O2 -DNDEBUG  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security
-- Building: Encodings
-- Building: XML
-- Building: JSON
-- Building: Util
-- Building: Net
-- Building: MongoDB
-- Building: Redis
-- Building: NetSSL_OpenSSL
-- Building: Crypto
-- Building: Data
-- Building: Zip
-- Building: PageCompiler
-- Building: File2Page
-- Configuring done
CMake Error at NetSSL_OpenSSL/CMakeLists.txt:16 (add_library):
  Target "NetSSL" links to target "OpenSSL::SSL" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

...

What I'm doing wrong?

CodePudding user response:

The solution for this question was use static libraries from OpenSSL. So, you need to link against .a instead of .so/.dylib. Something like:

cmake -H. -B./poco-build-x86 -G'Ninja' -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/Users/juangarcia/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/Users/juangarcia/Library/Android/android-ndk-r19c/build/cmake/android.toolchain.cmake -DCMAKE_C_COMPILER=/Users/juangarcia/Library/Android/android-ndk-r19c/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -DCMAKE_CXX_COMPILER=/Users/juangarcia/Library/Android/android-ndk-r19c/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang   -DANDROID_NATIVE_API_LEVEL=24 -DANDROID_ABI=x86 -DOPENSSL_CRYPTO_LIBRARY=/Users/juangarcia/Downloads/openssl_111_android/lib/x86/libcrypto.a -DOPENSSL_SSL_LIBRARY=/Users/juangarcia/Downloads/openssl_111_android/lib/x86/libssl.a -DOPENSSL_USE_STATIC_LIBS=TRUE -DENABLE_NETSSL=TRUE -DOPENSSL_INCLUDE_DIR=/Users/juangarcia/Downloads/openssl_111_android/inc/x86 -DCMAKE_INSTALL_PREFIX=install-x86

You should note that in the command above, I'm setting CMAKE_INSTALL_PREFIX to auto install in a directory, but it is not necessary to solve the question.

  • Related