首页 > 解决方案 > Android 未定义对 ANativeWindow_setBuffersTransform API 的引用

问题描述

我在尝试使用 ANativeWindow_setBuffersTransform API 时收到以下链接错误。编译的 SDK 版本为 28

undefined reference to `ANativeWindow_setBuffersTransform'

在我的 CMAKE 文件中,我将目标库与 android 库链接

target_link_libraries( # Specifies the target library.
        native-lib
        android
        GLESv2
        EGL
        realsense2
        libpcl_recognition
        libpcl_tracking
        libpcl_registration
        libpcl_stereo
        libpcl_segmentation
        libpcl_ml
        libpcl_keypoints
        libpcl_features
        libpcl_2d
        libpcl_surface
        libpcl_io_ply
        libpcl_io
        libpcl_filters
        libpcl_sample_consensus
        libpcl_search
        libpcl_octree
        libpcl_kdtree
        libpcl_common
        libboost_date_time
        libboost_filesystem
        libboost_iostreams
        libboost_program_options
        libboost_regex
        libboost_signals
        libboost_system

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

在我的源代码文件中,我包含了标题

#include <android/native_window.h>

我还可以使用其他 NativeWindow 功能,例如

ANativeWindow_lock
ANativeWindow_setBuffersGeometry
ANativeWindow_unlockAndPost

编译器抱怨的只是 ANativeWindow_setBuffersTransform 。

有人有什么主意吗 ?是否有人能够成功调用此功能并可以分享一些信息?提前致谢。

标签: androidandroid-ndkegl

解决方案


ANativeWindow_setBuffersTransform 存在于 nativewindow.so 中,在 CMAKE 中只需将 nativewindow 添加到链接库列表中,它应该编译和链接


推荐阅读