【问题标题】:Using C library in Android NDK with external dependency在具有外部依赖关系的 Android NDK 中使用 C 库
【发布时间】:2013-05-24 22:38:52
【问题描述】:

我有一个用 C 语言编写的 OCR 库,我希望使用本机开发工具包 (NDK) 在 Android 上运行。我是一位经验丰富的 Android 开发人员,但不使用 NDK(或 C)。我已经设置了许多hello world示例程序,现在我认为我需要回答的第一个问题是:

OCR 库需要 makefile 中的另一个依赖项:libtiff,它提供对 .TIFF 图像文件的支持。如何将此依赖项添加到项目中并在 Android.mk 文件中表示它?谁能链接到任何类似的例子?

以下是 OCR 生成文件中的一些代码:

TIFF    = {your_tiff_path}/libtiff.a
INCLUDES= {your_tiff_path}/include
DEFS    = -DDO_USE_32BIT -DLUT_POPCNT -DTIFF_FORMAT
OPT     = -O3
CFLAGS  = $(OPT) -g $(INCLUDES) $(PROFILE) $(DEFS)
# Add -m32 to build 32bit on 64bit machine
CC      = gcc -m32
LDFLAGS = $(OPT) $(PROFILE)

OBJECTS = cputime.o BitArr.o bits.o chardat.o symbol.o page.o get_skew.o \
    ccrx.o readtiff.o label.o glyph.o loadcontrols.o loadbestfont.o \
    qsegment.o makeBnodes.o makeLnodes.o runocr.o lineocr.o extract.o \
    splitchars.o compare.o scoreit.o lm_class.o lmdp.o \
    ocrfont.o glyphsubs.o binio.o ocrmain.o unicode.o

TARGET = ccr8

$(TARGET):  $(OBJECTS)
    $(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(TIFF) -lm -lc 

label.o:        label.c page.h CCR.h BitArr.h bits.h 
...
...
...

【问题讨论】:

  • 你有没有为Android编译过这个libtiff.a?实际上,也许您应该考虑“独立工具链”——这是一个为 Android 重用通用 makefile 的工具。您使用 NDK 安装的文档中对此进行了详细描述。
  • 我能够使用独立的工具链。如果您将评论变成答案,我会接受。谢谢!

标签: android c android-ndk cross-compiling libtiff


【解决方案1】:

使用“独立工具链”——这是一个为 Android 重用通用 makefile 的工具。您使用 NDK 安装的文档中对此进行了详细描述。

【讨论】:

    猜你喜欢
    • 2017-04-23
    • 1970-01-01
    • 2015-10-11
    • 2020-09-06
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 2013-09-12
    • 2013-06-03
    相关资源
    最近更新 更多