本文介绍了带有 NDK 的 Android Studio:链接错误:未定义对“stderr"的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译了针对 android armeabi-v7a 的 OpenCV 静态库.

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

现在我正在尝试通过 Android Studio 中的 CMakeLists.txt 文件将我的本机 C++ 代码与这些库链接,但由于这个奇怪的错误而失败:

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'

此代码来自 libopencv_videoio.a

This code comes from the libopencv_videoio.a

CMakeLists.txt 文件的有趣部分是这个

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 ?

编辑 1:以下是我的 Application.mk

EDIT 1:Following is my Application.mk

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

取自 Changelog.md 的 NDK 版本:r17b

NDK version taken from Changelog.md : r17b

编辑 2:

正如丹建议的那样,我添加了

As Dan suggested, I've added

"-DANDROID_PLATFORM=android-24"

到 cmake 参数

推荐答案

最可能的情况是您为 android-23+ 构建了 opencv,但 native-lib 的 minSdkVersion 低于此.请参阅 https:///android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md#using-mismatched-prebuilt-libraries.

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.

这篇关于带有 NDK 的 Android Studio:链接错误:未定义对“stderr"的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:09