gpt4 book ai didi

android - 无法使用 NDK 编译 harfbuz_ng 库

转载 作者:行者123 更新时间:2023-11-29 21:30:42 26 4
gpt4 key购买 nike

我正在开发一个应用程序,我正在使用 indic-text-renderer用于 devnagri 文本渲染。因为这是 NDK 库;我正在尝试使用 ndk-build 命令编译它。但它给了我以下错误:

Android NDK: Trying to define local module 'harfbuzz_ng' in /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.
Android NDK: But this module was already defined by /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.

我的 android.mk 文件是:

    LOCAL_PATH := $(call my-dir)

MY_LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm

LOCAL_MODULE := complex-script-rendering

LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/harfbuzz-ng/src

LOCAL_SRC_FILES := complex-script-rendering.c

LOCAL_STATIC_LIBRARIES := ft2 harfbuzz

LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)

include $(MY_LOCAL_PATH)/freetype/Android.mk

include $(MY_LOCAL_PATH)/harfbuzz-ng/Android.mk

JNI-hierarchy

我该如何解决这个错误?

我是 NDK 编程的新手,所以如果这些信息还不够,请告诉我

编辑:

freetype/Android.mk

ifndef USE_FREETYPE
USE_FREETYPE := 2.4.2
endif

ifeq ($(USE_FREETYPE),2.4.2)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

# compile in ARM mode, since the glyph loader/renderer is a hotspot
# when loading complex pages in the browser
#
LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES:= \
src/base/ftbbox.c \
src/base/ftbitmap.c \
src/base/ftfstype.c \
src/base/ftglyph.c \
src/base/ftlcdfil.c \
src/base/ftstroke.c \
src/base/fttype1.c \
src/base/ftxf86.c \
src/base/ftbase.c \
src/base/ftsystem.c \
src/base/ftinit.c \
src/base/ftgasp.c \
src/raster/raster.c \
src/sfnt/sfnt.c \
src/smooth/smooth.c \
src/autofit/autofit.c \
src/truetype/truetype.c \
src/cff/cff.c \
src/psnames/psnames.c \
src/pshinter/pshinter.c

LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/builds \
$(LOCAL_PATH)/include

LOCAL_CFLAGS += -W -Wall
LOCAL_CFLAGS += -fPIC -DPIC
LOCAL_CFLAGS += "-DDARWIN_NO_CARBON"
LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY"

# the following is for testing only, and should not be used in final builds
# of the product
#LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER"

LOCAL_CFLAGS += -O2

LOCAL_MODULE:= libft2

include $(BUILD_STATIC_LIBRARY)
endif

harfbuzz-ng/android.mk

LOCAL_PATH:= $(call my-dir)

HARFBUZZ_SRC_FILES = \
src/hb-blob.cc \
src/hb-buffer-serialize.cc \
src/hb-buffer.cc \
src/hb-common.cc \
src/hb-fallback-shape.cc \
src/hb-face.cc \
src/hb-font.cc \
src/hb-ot-tag.cc \
src/hb-set.cc \
src/hb-shape.cc \
src/hb-shape-plan.cc \
src/hb-shaper.cc \
src/hb-tt-font.cc \
src/hb-unicode.cc \
src/hb-warning.cc \
src/hb-ot-layout.cc \
src/hb-ot-map.cc \
src/hb-ot-shape.cc \
src/hb-ot-shape-complex-arabic.cc \
src/hb-ot-shape-complex-default.cc \
src/hb-ot-shape-complex-indic.cc \
src/hb-ot-shape-complex-indic-table.cc \
src/hb-ot-shape-complex-myanmar.cc \
src/hb-ot-shape-complex-sea.cc \
src/hb-ot-shape-complex-thai.cc \
src/hb-ot-shape-normalize.cc \
src/hb-ot-shape-fallback.cc

#############################################################
# build the harfbuzz library
#

include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-icu.cc

LOCAL_CPP_EXTENSION := .cc

LOCAL_SHARED_LIBRARIES := \
libcutils \
libicuuc \
libicui18n \
libutils

LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/src \
external/icu4c/common

LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU

LOCAL_LDLIBS += -lpthread

LOCAL_MODULE:= libharfbuzz_ng

include $(BUILD_SHARED_LIBRARY)

#############################################################
# build the harfbuzz static library
#
include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-ucdn.cc \
src/hb-ucdn/ucdn.c

LOCAL_CPP_EXTENSION := .cc
LOCAL_STATIC_LIBRARIES := libft2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/src \
external/freetype/include
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_UCDN -DHAVE_FREETYPE
LOCAL_LDLIBS += -lpthread

LOCAL_MODULE:= libharfbuzz_ng

include $(BUILD_STATIC_LIBRARY)

最佳答案

我尝试删除整个 BUILD_SHARED_LIBRARY block ,它不再提示重新定义问题,因为我想将 harfbuzz-ng 编译为静态库。你可以试一试。

我最后一次遇到这个错误是在我交叉编译 freetype 并将其用作项目中的预构建静态库时,我导出了 NDK-MODULE-PATH,但在我的 jni/Android 中有一行。 mk写成include $(MY_LOCAL_PATH)/freetype/Android.mk

所以我只是注释掉这一行,一切正常。

因为当您设置 NDK-MODULE-PATH 时,编译器将查看您的 PATH 目录并搜索 Android.mk 并使用它编译源代码。请引用this ,希望对您有所帮助。

关于android - 无法使用 NDK 编译 harfbuz_ng 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19632241/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com