Android Studio with NDK : link error : undefined reference to 'stderr'

五迷三道 提交于 2021-02-07 04:22:09

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/51767214/android-studio-with-ndk-link-error-undefined-reference-to-stderr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!