Search code examples
androidcompilationstatic-librariesspeex

Compile speex in Android (STATIC_LIBRARY)


I'm trying to compile the Speex library in Android. When I compile this library in shared mode, everything is ok, but when I try compile it in static mode the ndk seem do nothing and the library it not generates.

I've read that I only have to change include $(BUILD_SHARED_LIBRARY) by (BUILD_STATIC_LIBRARY) but this does not work and the library is not compiled and I don't get any error in the console.

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := speex

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_CFLAGS += -DHAVE_NEON=1
endif

LOCAL_CFLAGS += -DHAVE_CONFIG_H

LOCAL_C_INCLUDES := ../include   \
               ../libspeex   \
               ../           \

LOCAL_SRC_FILES := ../libspeex/bits.c      \
           ../libspeex/buffer.c    \
           ../libspeex/cb_search.c \
               ...
           ../libspeex/vq.c        \
           ../libspeex/window.c    \

LOCAL_CFLAGS += -DANDROID

include $(BUILD_STATIC_LIBRARY)

Application.mk

APP_PROJECT_PATH := $(call my-dir)
APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk
APP_STL := stlport_static
STLPORT_FORCE_REBUILD := true
APP_ABI := armeabi-v7a armeabi
APP_OPTIM := release 
APP_PLATFORM :=  android-8

What is wrong? Why does the NDK not compile the library?


Solution

  • I've solved it specifying in the same Android.mk, a module compiled in shared mode that uses the static library compiled before:

    Android.mk

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE    := speex-static
    
    ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
        LOCAL_CFLAGS += -DHAVE_NEON=1
    endif
    
    LOCAL_CFLAGS += -DHAVE_CONFIG_H
    
    LOCAL_C_INCLUDES := ../include   \
                   ../libspeex   \
                   ../           \
    
    LOCAL_SRC_FILES := ../libspeex/bits.c      \
               ../libspeex/buffer.c    \
               ../libspeex/cb_search.c \
                   ...
               ../libspeex/vq.c        \
               ../libspeex/window.c    \
    
    LOCAL_CFLAGS += -DANDROID
    
    include $(BUILD_STATIC_LIBRARY)
    
    include $(CLEAR_VARS)
    ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
        LOCAL_CFLAGS += -DHAVE_NEON=1
    endif
    LOCAL_MODULE := speex
    LOCAL_STATIC_LIBRARIES := speex-static
    LOCAL_CFLAGS += -DANDROID
    include $(BUILD_SHARED_LIBRARY)