编译问题为Android NDK的C语言库 [英] Problems compiling a C library for the Android NDK
问题描述
我需要一些建议。我试图使用 oRTP ,这是一个C ++库,在我的Android应用程序。我有oRTP源。至于我可以告诉什么,我需要做的就是编译oRTP到使用NDK构建一个静态库。然后,我需要写周围libortp其中函数是按照JNI的约定命名为C包装。我需要知道的是:
- 是Android.mk文件应该正确编译库?因为在其上运行NDK的构建不工作(无输出,没有文件创建)。
- 是我上面列出正确的还是有一个更简单的方法程序?
好,我知道它的工作。提供的Android.mk文件是正确的。它只是如果你把它当作是不会做任何事情。您需要使用静态库编译器做一些事来编译东西。在我的情况下,我增加了code下面的Android.mk文件的底部。 rtpsendc.c是一个C文件里面有code使用libortp。
包含$(CLEAR_VARS)
LOCAL_MODULE:= ortpwrapper
LOCAL_SRC_FILES:= rtpsendc.c
LOCAL_STATIC_LIBRARIES:= ortp
LOCAL_C_INCLUDES + = \\
$(LOCAL_PATH)\\
$(LOCAL_PATH)/包括:
LOCAL_LDLIBS:= -llog包括$(BUILD_SHARED_LIBRARY)
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:
- 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).
- Is the procedure I outlined above correct or is there a simpler way?
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)
这篇关于编译问题为Android NDK的C语言库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!