• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps NDK, Eclipse - Native Libraries Won't Build

paulscode

Member
Mar 18, 2010
86
14
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:
# If SDL_Mixer should link to libMAD
SDL_MIXER_USE_LIBMAD :=
ifneq ($(strip $(filter mad, $(COMPILED_LIBRARIES))),)
SDL_MIXER_USE_LIBMAD := 1
endif
ifneq ($(findstring -crystax,$(TARGET_CC)),)
$(info Building with CrystaX toolchain - RTTI and exceptions enabled, STLPort disabled)
CRYSTAX_TOOLCHAIN=1
endif
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:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := xml2
LOCAL_CFLAGS := -Os -I$(LOCAL_PATH) -I$(LOCAL_PATH)/include
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := \
    SAX.c entities.c encoding.c error.c \
    parserInternals.c parser.c tree.c hash.c list.c xmlIO.c \
    xmlmemory.c uri.c valid.c xlink.c HTMLparser.c HTMLtree.c \
    debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c \
    DOCBparser.c catalog.c globals.c threads.c c14n.c xmlstring.c \
    xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
    xmlreader.c relaxng.c dict.c SAX2.c xmlwriter.c legacy.c \
    chvalid.c pattern.c xmlsave.c xmlmodule.c schematron.c \
    triostr.c trio.c trionan.c
LOCAL_SHARED_LIBRARIES := 
LOCAL_STATIC_LIBRARIES :=
LOCAL_LDLIBS := -lz -ldl
include $(BUILD_SHARED_LIBRARY)
Let me know if you require any further information (sorry if I've left out something obvious).
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones