Ask Your Question
0

Need "How To" to Rebuild OpenCV v2.4.12 and v.3.1 for Android and NDK 11

asked 2016-03-31 13:45:33 -0500

I trying to rebuild OpenCV static libraries for the Android ABIs of: armeabi, armeabi-7a, mips, x86.

I'm using Android Studio (because Eclipse is deprecated) latest and greatest version on Mac OS X.

I using NDK 11 that recommends Clang3.8, GCC is deprecated. Use the APP_STL (Application.mk) of libc++ instead of libstdc++.

Threading Building Blocks (libtbb.a) support: clearly indicate or configure in CMake generator for Android on Mac OS X whether tbb is supported for one more of the Android ABIs.

My current problem is the following link error building a shared library for an Android APK where a static library created by the OpenCV Android armeabi-7a CMake build does not link with libtbb.a, that was created by the same build process:
.../libopencv_imgproc.a(histogram.cpp.o):
histogram.cpp:
function tbb::interface7::internal::auto_partition_type::auto_partition_type(tbb::auto_partitioner const&):
error: undefined reference to 'tbb::internal::get_initial_auto_partitioner_divisor()'
[Many more errors like this one...]

Here is my cmake command: cmake \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_WITH_DEBUG_INFO=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_TBB=ON \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all" \
-DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all -fvisibility-inlines-hidden" \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 \
-DANDROID_STL=c++_static \
-DANDROID_NATIVE_API_LEVEL=android-15 \
-DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake \
../..

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-04-01 03:42:38 -0500

mshabunin gravatar image

You can try to use build_sdk.py script for 3.x version. Here is an example build log: build log

python ../opencv/platforms/android/build_sdk.py . ../opencv

Run with --help to see available parameters. And don't forget to set ANDROID_SDK and ANDROID_NDK environment variables.

edit flag offensive delete link more
0

answered 2016-04-08 12:54:06 -0500

The link error resulted from me fat fingering a change of an assign operator, ":=", to a plus-equal operator, "+=", in the OpenCV produced OpenCV.mk file for Android cross-compilation. But the overall problem with CMake generated build environments remain. That is the initial CMake configuration definition settings are only known to the CMake project author. This requires the CMake project author to correctly and clearly document the CMake definitions that will build the specific target, whether it is a cross-compiling build environment or a platform specific build environment. Without proper documentation, it's is very hard to reverse engineer the CMake project/script/package, whatever you call it, to figure how platform specific build configuration settings map to CMake configuration definitions.

edit flag offensive delete link more

Comments

The documentation can be found in the file header: toolchain file

mshabunin gravatar imagemshabunin ( 2016-04-12 10:54:16 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-03-31 13:45:33 -0500

Seen: 679 times

Last updated: Apr 08 '16