Error when building POCO for Android with NETSSL support - android

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?

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

Cross-compile OpenCV on Linux Host for Android Target: Errors during Cmake configuration

Problem Description:
I am trying to compile OpenCV 4.5.1 on Ubuntu 20.04 LTS for Android (aarch64) with OpenCL support (since the stock OpenCV Android SDK does not have OpenCL support activated). I largely followed this tutorial covering the cross-compilation of OpenCV.
When trying to configure the build, Cmake seems to be unable to correctly create/locate all the necessary folders and thus throws an error (see cmake output below).
I suspect that it might have something to do with Cmake struggling to recognise the ant installation correctly (as indicated by the missing version number following the ant path in the Cmake output).
I have set the environment variables for the ANT executable as well as the Java Home folder through the Cmake build flags (see Cmake command below).
When looking at the error messages at the bottom of the Cmake output, it becomes clear that there is some problem with creating the necessary Android and/or Java folders. Upon inspection of modules/java/android_sdk/CMakeLists.txt (see extract below) I noticed that the variable OPENCV_JAVA_DIR should probably be set at some earlier stage in the cmake configuration. However, when running my command pasted below, this variable remains empty and hence cmake cannot access the folders since the path is not correct.
These are the values of the variables when running my cmake configuration command:
-- OPENCV_JAVA_DIR = /opencv
-- ANDROID_EXECUTABLE = FALSE
-- ANDROID_BUILD_BASE_DIR =
-- OpenCV_BINARY_DIR= /home/flavio/Downloads/opencv/build_manual
Is there some configuration error in my Cmake buildflags or something entirely different that I am doing wrong?
Thanks for you help!
Related Questions
Cmake cannot find ant
Cmake cannot recognise Java
Ant for Java not showing as installed eventhough it is
I have tried all the proposed changes, so far with no success. Reinstallation of ant did not help, neither creating a symlink to the executable store at /usr/share/ant/bin/ant in /usr/bin.
Cmake Command used (in build folder inside the downloaded opencv-source):
cmake \
-DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk/21.0.6113669/build/cmake/android.toolchain.cmake \
-DANDROID_TOOLCHAIN=clang++ \
-DANDROID_ABI=arm64-v8a \
-DANDROID_TARGET_SDK_VERSION=26 \
-DANDROID_MIN_SDK_VERSION=24 \
-DBUILD_JAVA=ON -DBUILD_FAT_JAVA_LIB=ON DBUILD_ZLIB=ON \
-D CMAKE_BUILD_TYPE=Release \
-D ANDROID_NATIVE_API_LEVEL=24 \
-DANDROID_COMPILE_SDK_VERSION=26 \
-D ANDROID_STL=c++_shared \
-D WITH_CUDA=OFF \
-D WITH_MATLAB=OFF \
-D BUILD_ANDROID_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=ON -D BUILD_SHARED_LIBS=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_JNI=ON \
-DWITH_OPENCL=ON -DWITH_OPENGL=ON \
-DANT_HOME=/usr/share/ant -DJAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 -DANT_EXECUTABLE=/bin/ant \
-DSTRIP=/home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip \
..
Extract from modules/java/android_sdk/CMakeList.txt:
project(${the_module}_android)
if(ANDROID_EXECUTABLE)
set(OPENCV_JAVA_DIR "${OpenCV_BINARY_DIR}/android_sdk" CACHE INTERNAL "")
else() # gradle
set(OPENCV_JAVA_DIR "${ANDROID_BUILD_BASE_DIR}/opencv" CACHE INTERNAL "")
endif()
set(OPENCV_ANDROID_LIB_DIR "${OPENCV_JAVA_DIR}" CACHE INTERNAL "") # for OpenCV samples
message (STATUS "OPENCV_JAVA_DIR = ${OPENCV_JAVA_DIR}")
message (STATUS "ANDROID_BUILD_BASE_DIR = ${ANDROID_BUILD_BASE_DIR}")
message (STATUS "OpenCV_BINARY_DIR= ${OpenCV_BINARY_DIR}")
file(REMOVE_RECURSE "${OPENCV_JAVA_DIR}")
file(MAKE_DIRECTORY "${OPENCV_JAVA_DIR}/bin")
set(java_src_dir "${OPENCV_JAVA_DIR}/src")
file(MAKE_DIRECTORY "${java_src_dir}")
Cmake terminal output
-- Check for working CXX compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: aarch64
CMake Warning at cmake/OpenCVUtils.cmake:752 (message):
Unexpected option: WITH_OPENGL (=ON)
Condition: IF (NOT;ANDROID;AND;NOT;WINRT)
Call Stack (most recent call first):
CMakeLists.txt:308 (OCV_OPTION)
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.18", minimum required is "2.7")
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3.2")
-- Looking for ccache - not found
<---------- Performed Tests have been cut out from this output to meet character-limit of stackoverflow questions ----------->
-- ANDROID: TRUE
-- Update variable ANDROID_SDK_ROOT from environment: /home/flavio/Android/Sdk
-- Update variable ANDROID_HOME from environment: /home/flavio/Android/Sdk
Android: Projects builds are DISABLED
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- ADE: Download: v0.1.1f.zip
-- Allocator metrics storage type: 'int'
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.ssse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_1.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin512.avx512_skx.cpp
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/flavio/Downloads/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- OPENCV_JAVA_DIR = /opencv
-- ANDROID_BUILD_BASE_DIR =
-- OpenCV_BINARY_DIR= /home/flavio/Downloads/opencv/build_manual
CMake Error at modules/java/android_sdk/CMakeLists.txt:15 (file):
file problem creating directory: /opencv/bin
CMake Error at modules/java/android_sdk/CMakeLists.txt:17 (file):
file problem creating directory: /opencv/src
CMake Error: Could not open file for write in copy operation /opencv/AndroidManifest.xml.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
configure_file Problem configuring file
CMake Error: Could not open file for write in copy operation /opencv/build.gradle.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
configure_file Problem configuring file
CMake Error: Could not open file for write in copy operation /opencv/res/values/attrs.xml.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:121 (configure_file):
configure_file Problem configuring file
CMake Error: Could not open file for write in copy operation /opencv/libcxx_helper/CMakeLists.txt.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:133 (configure_file):
configure_file Problem configuring file
CMake Error: Could not open file for write in copy operation /opencv/libcxx_helper/dummy.cpp.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:133 (configure_file):
configure_file Problem configuring file
CMake Error: Could not open file for write in copy operation /opencv/build.gradle.tmp
CMake Error: : System Error: No such file or directory
CMake Error at modules/java/android_sdk/CMakeLists.txt:160 (configure_file):
configure_file Problem configuring file
-- Android OpenCV Manager is ignored
--
-- General configuration for OpenCV 4.5.1 =====================================
-- Version control: unknown
--
-- Platform:
-- Timestamp: 2022-03-20T09:57:50Z
-- Host: Linux 5.13.0-35-generic x86_64
-- Target: Android 1 aarch64
-- CMake: 3.16.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON FP16
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ (ver 9.0)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -DDEBUG -D_DEBUG
-- C Compiler: /home/flavio/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: ade dl m log
-- 3rdparty dependencies: libcpufeatures ittnotify libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo stitching ts video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: python2 python3
-- Applications: tests
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Android NDK: /home/flavio/Android/Sdk/ndk/21.0.6113669 (ver 21.0.6113669)
-- Android ABI: arm64-v8a
-- NDK toolchain: aarch64-linux-android-4.9
-- STL type: c++_shared
-- Native API level: 24
-- Android SDK: not used, projects are not built
--
-- GUI:
-- OpenGL support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.0.6-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.0.10)
-- JPEG 2000: build (ver 2.3.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/flavio/Downloads/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python (for build): /usr/bin/python2.7
--
-- Java: export all functions
-- ant: /bin/ant (ver )
-- Java wrappers: YES
-- Java tests: NO
--
-- Install to: /home/flavio/Downloads/opencv/build_manual/install
-- -----------------------------------------------------------------
--
-- Configuring incomplete, errors occurred!
See also "/home/flavio/Downloads/opencv/build_manual/CMakeFiles/CMakeOutput.log".
See also "/home/flavio/Downloads/opencv/build_manual/CMakeFiles/CMakeError.log".
I had similar errors, so I fixed it by turning on -DBUILD_ANDROID_PROJECTS=ON and fix all incompatible "SDK TOOL version" or "gradle versions". Then gradle can set all necessary paths like ANDROID_BUILD_BASE_DIR in modules/java/android_sdk/CMakeLists.txt:15.
For example to update SDK Tools: Open android studio > setting > system settings > Android SDK > SDK Tools > update Android SDK build tools and NDK(side by side)

C/C++ configuration problem in android studio 4 after gradle sync

I am trying to integrate native (C++) OpenCV code into my project. I am following this project on github. After I click refresh linked C++ projects the compiler exits with exit code 1.
2:48 AM Gradle sync finished in 3 s 67 ms
2:48 AM C/C++ Configuration Problem
native-lib | debug | x86
Compiler exited with error code 1: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -xc++ --target=i686-none-linux-android24 --gcc-toolchain=/home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dnative_lib_EXPORTS -isystem /home/user/Downloads/forLinux/android studio/opencv-4.3.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -O0 -fno-limit-debug-info -fPIC -std=gnu++11 -fpch-preprocess -v -dD -E
Android (5900059 based on r365631c) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290) (based on LLVM 9.0.8svn)
Target: i686-none-linux-android24
Thread model: posix
Dir: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x
Found candidate GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x
Selected GCC installation: /home/user/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x Candidate multilib: .;#m32
Selected multilib: .;#m32 clang++: error: no such file or directory: 'studio/opencv-4.3.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/include'
The folder containing open-cv sdk had a space in its name. Removing the space solved the error.

gradle build for android native project fails with "unable to open output file" error

I am trying to build an android native project using gradle. While the build passes for the architectures arm64-v8a, x86 and x86_64, it fails for armeabi-v7a with a unique error:
/{sdk-path}/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -frtti -fexceptions -Os -DNDEBUG -O2 -DNDEBUG -D_NDEBUG=1 -s -fPIC -Wdeprecated-declarations -std=c++14 -MD -MT CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o -MF CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o.d -o CMakeFiles/acplocalnet.dir/src/main/cpp/HttpTransferCallbackHookImpl.cpp.o -c /Users/acpl/workspace/ACPLocal_net_Android/net/project/android/acplocalnet/app/src/main/cpp/HttpTransferCallbackHookImpl.cpp
clang++: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
error: unable to open output file '/apps/temp/HttpTransferCallbackHookImpl-baaa5e.s': 'No such file or directory'
1 error generated.
ninja: build stopped: subcommand failed.
The issue here is I am able to run this command and it builds the native libraries successfully when run the machine locally, but it fails when it is run through jenkins. The other amusing thing is that it fails only for the abi armeabi-v7a and passes for all other architectures.
I have verified the user, path and environment variables like ANDROID_HOME and ANDROID_NDK_HOME which are same when I run using the command line on the machine locally and when run using jenkins.
The command was not able to open the output files in the location "/apps/temp" as this directory was not present in the slave. This temp directory present in the jenkins master and was passed to the slave which was visible in the build variable TMP_DIR. Explicitly mentioning a valid temporary directory for the jenkins slave fixed the issue.

Android Studio NDK Build command failed (Missing c Compiler?)

I have tried several days installing the NDK into Android Studio but it always gives me an error message saying that the build failed and I should install a c compiler. I installed the NDK via the SDK Manager by checking the NDK and C Make.
I have already tried completely reinstalling Android Studio and the NDK but that did not work as well -same error.
Something maybe worth mentioning is that if I do not check the C++ support during the project creation there are no errors(but no c++ support too:D).
What should I do because it kills my workflow?
Thank you very much
The Error Message:
Blockquote
External Native Build Issues
Build command failed.
Error while executing process C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Julius Debus\Desktop\MyApplication\app -BC:\Users\Julius Debus\Desktop\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Julius Debus\Desktop\MyApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions -DCMAKE_TOOLCHAIN_FILE=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Julius
Debus/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_a4b3d"
[1/2] Building C object CMakeFiles/cmTC_a4b3d.dir/testCCompiler.c.o
FAILED:
C:\Users\JULIUS~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb
-Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_a4b3d.dir/testCCompiler.c.o -c "C:\Users\Julius
Debus\Desktop\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Julius Debus\Desktop\MyApplication\app -BC:\Users\Julius Debus\Desktop\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Julius Debus\Desktop\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions -DCMAKE_TOOLCHAIN_FILE=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Julius
Debus/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_82ebe"
[1/2] Building C object CMakeFiles/cmTC_82ebe.dir/testCCompiler.c.o
FAILED:
C:\Users\JULIUS~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb
-Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_82ebe.dir/testCCompiler.c.o -c "C:\Users\Julius
Debus\Desktop\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake
Warning:Warning:line (63) (include) CMakeLists.txt
Warning:Warning:line (63) (include) CMakeLists.txt
C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake
Error:Error:line (61)/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
Error:Error:line (61)/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File

Android Studio: External Native Build Issues

I cloned a project from a github repository and opened it in my Android Studio 3.0.
As soon as I open up Android Studio I get an Error:
Cannot load module file 'C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\Bookingtest.iml':
File C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\Bookingtest.iml does not exist
Would you like to remove module 'Bookingtest' from the project?
I don't understand why a file doesn't exist when I cloned the project right from the github.
Another Error that come up with the Gradle Sync is and External Native Build Issue.
External Native Build Issues
Build command failed.
Error while executing process C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app -BC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\release\armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\build\intermediates\cmake\release\obj\armeabi -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/David
Ferrara/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_93f60"
[1/2] Building C object CMakeFiles/cmTC_93f60.dir/testCCompiler.c.o
FAILED:
C:\Users\DAVIDF~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv5te-none-linux-androideabi --gcc-toolchain="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_93f60.dir/testCCompiler.c.o -c "C:\Users\David
Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\release\armeabi\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/release/armeabi/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app -BC:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\debug\armeabi -DANDROID_ABI=armeabi -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\David Ferrara\AndroidStudioProjects\ClBooking-master\app\build\intermediates\cmake\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=C:\Users\David Ferrara\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/David
Ferrara/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_17c6b"
[1/2] Building C object CMakeFiles/cmTC_17c6b.dir/testCCompiler.c.o
FAILED:
C:\Users\DAVIDF~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv5te-none-linux-androideabi --gcc-toolchain="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/David
Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
-Wformat -Werror=format-security -fPIE -o
CMakeFiles/cmTC_17c6b.dir/testCCompiler.c.o -c "C:\Users\David
Ferrara\AndroidStudioProjects\ClBooking-master\app\.externalNativeBuild\cmake\debug\armeabi\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Ferrara/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David Ferrara/AndroidStudioProjects/ClBooking-master/app/.externalNativeBuild/cmake/debug/armeabi/CMakeFiles/CMakeError.log".
C:\Users\David Ferrara\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake
Error:Error:line (61)/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
Error:Error:line (61)/Users/David Ferrara/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
I've tired to search for answers on this subject and have come across some answers that are similar to my question except they are not solutions for my specific question.
I'm stuck at a wall and don't know what to do to resolve this Error. All I want to do is clone a repo from github and work on the project in Android studio. All of my SDKs are installed.
This may be caused by the space in the folder C:/Users/David Ferrara/AppData/Local/
If so, it is likely a bug in Android Studio, CMake, or ninja

Categories

Resources