3

I've compiled OpenCV static libraries targeting android armeabi-v7a.

Now I'm trying to link my native C++ code with those libraries through a CMakeLists.txt file in Android Studio but this fails with this weird error :

~/opencv/modules/videoio/src/container_avi.cpp:0: error: undefined reference to 'stderr'

This code comes from the libopencv_videoio.a

The interresting part of the CMakeLists.txt file is this

# linking with static libraries
target_link_libraries(native-lib
     dnn ml objdetect shape stitching superres videostab calib3d features2d highgui videoio imgcodecs video photo imgproc flann core
)

Isn't it supposed to find standard libraries automatically ?

EDIT 1: Following is my Application.mk

...
NDK_TOOLCHAIN_VERSION := clang
APP_PLATFORM := android-21
APP_STL := c++_shared
...

NDK version taken from Changelog.md : r17b

EDIT 2:

As Dan suggested, I've added

"-DANDROID_PLATFORM=android-24"

to the cmake arguments

Olivier MATROT
  • 4,515
  • 5
  • 47
  • 77

1 Answers1

3

The most likely scenario is that you built opencv for android-23+ but native-lib has a minSdkVersion below that. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md#using-mismatched-prebuilt-libraries.

Dan Albert
  • 9,365
  • 2
  • 34
  • 76