我正在尝试为 Android 编译 libnice(具体为 v0.18),但遇到了一些麻烦。如何为 Android 编译 libnice?到目前为止,我已经在下面列出了我的尝试。
第一次尝试
我的第一次尝试是使用自定义的 Android.mk makefile,但我收到一条错误消息AI_NUMERICHOST undeclared
(添加#include <netdb.h>
并没有解决这个问题,我在这里没有想法)。请参阅下面的我的 Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := glib
LOCAL_SRC_FILES := lib/libglib-2.0.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gobject
LOCAL_SRC_FILES := lib/libgobject-2.0.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gmodule
LOCAL_SRC_FILES := lib/libgmodule-2.0.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gio
LOCAL_SRC_FILES := lib/libgio-2.0.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gthread
LOCAL_SRC_FILES := lib/libgthread-2.0.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffi
LOCAL_SRC_FILES := lib/libffi.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := iconv
LOCAL_SRC_FILES := lib/libiconv.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := intl
LOCAL_SRC_FILES := lib/libintl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := xml2
LOCAL_SRC_FILES := lib/libxml2.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := z
LOCAL_SRC_FILES := lib/libz.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
NICE := libnice-0.1.8
LOCAL_MODULE := ice_jni
LOCAL_LDLIBS := -llog
LOCAL_STATIC_LIBRARIES := glib gobject gmodule gio gthread ffi iconv intl xml2 z
NICE_INCLUDES := $(LOCAL_PATH)/include \
$(LOCAL_PATH)/lib/glib-2.0/include \
$(LOCAL_PATH)/lib/libffi-3.0.13/include \
$(wildcard $(LOCAL_PATH)/include/*) \
$(LOCAL_PATH)/$(NICE)/nice \
$(LOCAL_PATH)/$(NICE)/agent \
$(LOCAL_PATH)/$(NICE)/random \
$(LOCAL_PATH)/$(NICE)/socket \
$(LOCAL_PATH)/$(NICE)/stun
NICE_SRC := $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(NICE)/agent/*.c)) \
$(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(NICE)/random/*.c)) \
$(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(NICE)/socket/*.c)) \
$(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(NICE)/stun/*.c))
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(NICE_INCLUDES)
LOCAL_SRC_FILES := ICE.cpp \
$(NICE_SRC)
include $(BUILD_SHARED_LIBRARY)
静态库是从 gstreamer 1.4.1 调试版本复制过来的,并根据下面提到的指南进行选择。
第二次尝试
然后我尝试参考this guide编译一个静态库,这再次造成了麻烦:
export PKG_CONFIG_PATH=`pwd`/../gstreamer/lib/pkgconfig
export CFLAGS="--sysroot=`pwd`/../toolchain/sysroot"
./configure --prefix=`pwd`/../build --host=arm-linux-androideabi
这会导致以下错误。向 CFLAGS添加-mthumb
或会在配置期间-marm
产生C compiler cannot create executables
错误。
stunagent.c: Assembler messages:
stunagent.c:160: Error: no such instruction: `rev %eax,%eax'
stunagent.c:676: Error: no such instruction: `rev16 %ax,%ax'
提到的行不包含 ASM 但调用htons
and ntohl
,所以我想我做错了什么......
我make_standalone_toolchain
从 NDK 使用各种 Android 版本来创建工具链。
有人可以帮忙吗?提前致谢!~