NDK, Eclipse - Native Libraries Won't Build


Last Updated: 2010-12-01 22:50:03
  1. paulscode

    paulscode Well-Known Member

    Hello, all. I'm still new to the NDK and Eclipse, so this is probably an easy question. I have source code for several libraries that I want to have built into libs/armeabi/libNAME.so. Reading the documentation, it seems like all I should have to do is put the libraries into individual folders under the jni folder, create an Android.mk file in jni which has a call to "include $(call all-subdir-makefiles)", and another Android.mk in the sub-folder which has a call to "include $(BUILD_SHARED_LIBRARY)" I think these files are correct, so I'm not sure what I'm missing to have Eclipse/NDK actually build the libraries.

    For reference, the Android.mk file located in jni is:
    Code (Text):
    1. # If SDL_Mixer should link to libMAD
    2. SDL_MIXER_USE_LIBMAD :=
    3. ifneq ($(strip $(filter mad, $(COMPILED_LIBRARIES))),)
    4. SDL_MIXER_USE_LIBMAD := 1
    5. endif
    6. ifneq ($(findstring -crystax,$(TARGET_CC)),)
    7. $(info Building with CrystaX toolchain - RTTI and exceptions enabled, STLPort disabled)
    8. CRYSTAX_TOOLCHAIN=1
    9. endif
    10. include $(call all-subdir-makefiles)
    And an example of an Android.mk file for one of the libraries, located in a sub-folder under jni:
    Code (Text):
    1. LOCAL_PATH := $(call my-dir)
    2. include $(CLEAR_VARS)
    3. LOCAL_MODULE := xml2
    4. LOCAL_CFLAGS := -Os -I$(LOCAL_PATH) -I$(LOCAL_PATH)/include
    5. LOCAL_CPP_EXTENSION := .cpp
    6. LOCAL_SRC_FILES := \
    7.     SAX.c entities.c encoding.c error.c \
    8.     parserInternals.c parser.c tree.c hash.c list.c xmlIO.c \
    9.     xmlmemory.c uri.c valid.c xlink.c HTMLparser.c HTMLtree.c \
    10.     debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c \
    11.     DOCBparser.c catalog.c globals.c threads.c c14n.c xmlstring.c \
    12.     xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
    13.     xmlreader.c relaxng.c dict.c SAX2.c xmlwriter.c legacy.c \
    14.     chvalid.c pattern.c xmlsave.c xmlmodule.c schematron.c \
    15.     triostr.c trio.c trionan.c
    16. LOCAL_SHARED_LIBRARIES :=
    17. LOCAL_STATIC_LIBRARIES :=
    18. LOCAL_LDLIBS := -lz -ldl
    19. include $(BUILD_SHARED_LIBRARY)
    Let me know if you require any further information (sorry if I've left out something obvious).

    Advertisement
  2. paulscode

    paulscode Well-Known Member

    Aha! I figured it out - I just needed to select Android Tools->Add Native Support. I knew it would be something simple.

Share This Page