Ask Your Question

Revision history [back]

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

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 \
../..