简体   繁体   English

在具有外部依赖关系的Android NDK中使用C库

[英]Using C library in Android NDK with external dependency

I have an OCR library written in C that I wish to run on Android using the Native Development Kit (NDK). 我有一个用C编写的OCR库,希望使用本机开发套件(NDK)在Android上运行。 I am an experienced Android developer, but not with the NDK (or C for that matter). 我是一位经验丰富的Android开发人员,但没有使用NDK(或C)。 I have set-up numerous hello world sample programs, and now I think that the first question I need to answer is: 我已经建立了许多hello world示例程序,现在我认为我需要回答的第一个问题是:

The OCR library requires another dependency in the makefile: libtiff , which provides support for .TIFF image files. OCR库在makefile中需要另一个依赖项: libtiff ,它提供对.TIFF图像文件的支持。 How can I add this dependency to the project and represent it in an Android.mk file? 如何将这种依赖关系添加到项目中并在Android.mk文件中表示出来? Can anyone link to any similar examples? 任何人都可以链接到任何类似的示例吗?

Here is some code from the OCR makefile: 这是OCR makefile中的一些代码:

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 
...
...
...

Use the "standalone toolchain" - this is a tool to reuse generic makefiles for Android. 使用“独立工具链”-这是一个可为Android重用通用Makefile的工具。 It is well described in the docs that you installed with the NDK. 与NDK一起安装的文档中对此进行了很好的描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM