首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ndk-构建找不到库

ndk-构建找不到库
EN

Stack Overflow用户
提问于 2019-04-22 15:34:43
回答 1查看 1.4K关注 0票数 0

我正在尝试用ndk构建这个示例项目,但由于某种原因,它找不到库。这是我得到的错误消息:

build-binary.mk:688: Android : fastcvFeatDetect依赖于未定义的模块: log GLESv2

我对ndk不太了解,不知道如何检查这些库是否可用,以及我是否正确地指向了它们的路径。

在顶层有一个master文件:

代码语言:javascript
复制
# An Android.mk file must begin with the definition of the LOCAL_PATH variable.
# It is used to locate source files in the development tree. In this example,
# the macro function 'my-dir', provided by the build system, is used to return
# the path of the current directory (i.e. the directory containing the
# Android.mk file itself). 
#
LOCAL_PATH := $(call my-dir) 

JNI_DIR := $(LOCAL_PATH)
UTILS_DIR := $(LOCAL_PATH)/utils

# The function "$(call all-subdir-makefiles)" returns a list of Android.mk 
# files located in all sub-directories of the current 'my-dir' path.
# This function can be used to provide deep-nested source directory
# hierarchies to the build system.
#
include $(call all-subdir-makefiles)

以下是子目录中的生成文件:

代码语言:javascript
复制
LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE:= false

# This variable determines the OpenGL ES API version to use:
# If set to true, OpenGL ES 1.1 is used, otherwise OpenGL ES 2.0.

USE_OPENGL_ES_1_1 := false

# Set OpenGL ES version-specific settings.

ifeq ($(USE_OPENGL_ES_1_1), true)
    OPENGLES_LIB  := -lGLESv1_CM
    OPENGLES_DEF  := -DUSE_OPENGL_ES_1_1
else
    OPENGLES_LIB  := -lGLESv2
    OPENGLES_DEF  := -DUSE_OPENGL_ES_2_0
endif

# An optional set of compiler flags that will be passed when building
# C ***AND*** C++ source files.
#
# NOTE: flag "-Wno-write-strings" removes warning about deprecated conversion
#       from string constant to 'char*'

LOCAL_CFLAGS := -Wno-write-strings $(OPENGLES_DEF)

# The list of additional linker flags to be used when building your
# module. This is useful to pass the name of specific system libraries
# with the "-l" prefix.

LOCAL_LDLIBS := \
     -llog $(OPENGLES_LIB)
LOCAL_LDFLAGS:= -Wl,--no-fix-cortex-a8

LOCAL_MODULE    := libfastcvFeatDetect
LOCAL_CFLAGS    := -Werror
LOCAL_SRC_FILES := ../About.cpp Corner.cpp

LOCAL_STATIC_LIBRARIES := libfastcv libfastcvUtils
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_C_INCLUDES += $(JNI_DIR)/fastcv
LOCAL_C_INCLUDES += $(JNI_DIR)

LOCAL_MODULE_OWNER := qcom
LOCAL_PROPRIETARY_MODULE := true

include $(BUILD_SHARED_LIBRARY)

我尝试过在谷歌搜索的基础上改变一些东西,但到目前为止都没有效果。有人有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-29 18:03:40

代码语言:javascript
复制
LOCAL_PRELINK_MODULE:= false

这不是NDK样本。这是平台代码。它是由AOSP构建系统构建的,而不是NDK。有关这方面的更多信息,请参见https://source.android.com/setup/build/building

如果您想要找到NDK样本,请参见https://github.com/googlesamples/android-ndk

如果您确实需要使用NDK构建这个非NDK项目,请继续阅读。

$NDK/build中添加错误消息通常是查找更多信息的好方法:

代码语言:javascript
复制
$(call __ndk_warning,Module $(LOCAL_MODULE) depends on undefined modules: $(undefined_libs))

# https://github.com/android-ndk/ndk/issues/208
# ndk-build didn't used to fail the build for a missing dependency. This
# seems to have always been the behavior, so there's a good chance that
# there are builds out there that depend on this behavior (as of right now,
# anything using libc++ on ARM has this problem because of libunwind).
#
# By default we will abort in this situation because this is so completely
# broken. A user may define APP_ALLOW_MISSING_DEPS to "true" in their
# Application.mk or on the command line to revert to the old, broken
# behavior.
ifneq ($(APP_ALLOW_MISSING_DEPS),true)
    $(call __ndk_error,Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies))
endif

这过去常常被默默地忽略,现在它是一个错误。它指出了以下缺陷:

代码语言:javascript
复制
LOCAL_SHARED_LIBRARIES := liblog

这句话什么也做不了。把它删掉。系统库是与LOCAL_LDLIBS而不是LOCAL_SHARED_LIRBARIES链接的。在其他地方也会有类似的行导致GLESv2的错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55796908

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档