Johnny
Johnny

Reputation: 7351

Problems compiling a C library for the Android NDK

I need some advice. I'm trying to use oRTP, which is a C library, in my Android app. I have the source for oRTP. As far as I can tell what I need to do is to compile oRTP into a static library using ndk-build. Then I need to write a C wrapper around libortp where the functions are named according to the JNI's conventions. What I need to know is:

  1. Is the Android.mk file here supposed to compile the library correctly? Because running ndk-build on it doesn't work (no output, no files created).
  2. Is the procedure I outlined above correct or is there a simpler way?

Upvotes: 1

Views: 1071

Answers (1)

Johnny
Johnny

Reputation: 7351

OK, got it working. The supplied Android.mk file is correct. It just doesn't do anything if you use it as is. You need to compile something using the static library for the compiler to do something. In my case I added the code below to the bottom of the Android.mk file. rtpsendc.c is a c file which has code that uses libortp.

include $(CLEAR_VARS)
LOCAL_MODULE := ortpwrapper
LOCAL_SRC_FILES := rtpsendc.c
LOCAL_STATIC_LIBRARIES := ortp
LOCAL_C_INCLUDES += \
        $(LOCAL_PATH) \
        $(LOCAL_PATH)/include 
LOCAL_LDLIBS := -llog   

include $(BUILD_SHARED_LIBRARY)

Upvotes: 1

Related Questions