NDK开发 error: undefined referenc

2021-07-01  本文已影响0人  Kerwin_H

修改部分:

1、build.gradle(:app)

ndk {
                ldLibs "log"//实现__android_log_print
                abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
            }

如果报错:abis [armeabi] are not supported for platform. supported abis are [arm64-v8a, armeabi-v7a, x86, x86_
需要把abiFilters 后面的"armeabi"去掉,或者直接注释到abiFilters

2、修改CMakeLists.txt

目前自动生成的CMakeLists都带有以下代码,如果没有需要添加

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log )
target_link_libraries( # Specifies the target library.
        native-lib

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

特别注意!

如果生成不止一个文件(包括so文件和可运行文件!),需要每个文件都链接

target_link_libraries( # Specifies the target library.
        native-lib

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

target_link_libraries( # Specifies the target library.
        testcam

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

猜你喜欢

热点阅读