3

我是交叉编译的新手,我被分配了使用 android 补丁http://avahi.org/ticket/354将 avahi 核心编译到 android 的任务。ndk-build avahi-configure V=1 成功,但是当我运行:ndk-build V=1 NDK_LOG=2 APP_ABI="armeabi armeabi-v7a" 时,它会发出大量警告,并且在 socket.o 上也会出错

欢迎任何建议。

错误:/home/ruoruo/Software/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/if.h:85:12:警告:枚举器列表末尾的逗号 [-pedantic ] /home/ruoruo/Software/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/if.h:90:22:警告:枚举器列表末尾的逗号 [-pedantic] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:68:8: 错误:重新定义'struct in6_pktinfo' /home/ruoruo/Software/android-ndk- r8b/platforms/android-14/arch-arm/usr/include/linux /ipv6.h:21:8: 注意:最初定义在这里/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/ avahi-core/socket.c:在函数“avahi_mdns_mcast_join_ipv6”中:​​/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:150:64:警告:未使用的参数'a' [-Wunused-parameter] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv4'中:/home/ruoruo/Software /android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:647:9:警告:变量'found_addr'设置但未使用[-Wunused-but-set-variable] /home/ruoruo/软件/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core /socket.c:809:24:警告:变量 'found_iface' 已设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi- core/socket.c:809:9: 警告:变量 'found_ttl' 设置但未使用 [-Wunused-but-set-variable] make:[-Wunused-parameter] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv4'中:/home/ruoruo/Software/android-ndk- r8b/samples/avahi_exports/jni/avahi-core/socket.c:647:9:警告:变量'found_addr'设置但未使用[-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk -r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c: 809:24:警告:变量 'found_iface' 已设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c :809:9:警告:变量'found_ttl'设置但未使用[-Wunused-but-set-variable] make:[-Wunused-parameter] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv4'中:/home/ruoruo/Software/android-ndk- r8b/samples/avahi_exports/jni/avahi-core/socket.c:647:9:警告:变量'found_addr'设置但未使用[-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk -r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c: 809:24:警告:变量 'found_iface' 已设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c :809:9:警告:变量'found_ttl'设置但未使用[-Wunused-but-set-variable] make:avahi_recv_dns_packet_ipv4':/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:647:9:警告:变量'found_addr'设置但未使用[-Wunused-but-设置变量] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/ruoruo/Software/android-ndk-r8b/ samples/avahi_exports/jni/avahi-core/socket.c:809:24:警告:变量 'found_iface' 已设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b /samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量 'found_ttl' 已设置但未使用 [-Wunused-but-set-variable] 使:avahi_recv_dns_packet_ipv4':/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:647:9:警告:变量'found_addr'设置但未使用[-Wunused-but-设置变量] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/ruoruo/Software/android-ndk-r8b/ samples/avahi_exports/jni/avahi-core/socket.c:809:24:警告:变量 'found_iface' 已设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b /samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量 'found_ttl' 已设置但未使用 [-Wunused-but-set-variable] 使:设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/如若/软件/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:24:警告:变量'found_iface'设置但未使用[-Wunused-but-set-variable] /home /ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量'found_ttl'设置但未使用[-Wunused-but-set-variable] make :设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:在函数'avahi_recv_dns_packet_ipv6'中:/home/如若/软件/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:24:警告:变量'found_iface'设置但未使用[-Wunused-but-set-variable] /home /ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量'found_ttl'设置但未使用[-Wunused-but-set-variable] make :设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量'found_ttl ' 设置但未使用 [-Wunused-but-set-variable] make:设置但未使用 [-Wunused-but-set-variable] /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni/avahi-core/socket.c:809:9:警告:变量'found_ttl ' 设置但未使用 [-Wunused-but-set-variable] make:* [/home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/obj/local/armeabi/objs/avahi-core/socket.o] 错误1

这是我的 Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

AVAHI_TOP := /home/ruoruo/Software/android-ndk-r8b/samples/avahi_exports/jni
CONFIGURE := configure
CONFIGURE_LDFLAGS := -lc -ldl

AVAHI_BUILT_SOURCES := \
    avahi-common/Android.mk \
    avahi-core/Android.mk \
    avahi-client-uninstalled.pc \
    avahi-client/Android.mk \
    avahi-utils/Android.mk \
    avahi-glib/Android.mk \
    avahi-glib-uninstalled.pc \
    avahi-gobject/Android.mk \
    avahi-gobject-uninstalled.pc \
    avahi-daemon/Android.mk

avahi-configure-real:
    cd $(AVAHI_TOP) ; \
#    CC="$(CONFIGURE_CC)" \
#    CFLAGS="$(CONFIGURE_CFLAGS)" \
#    LD=$(TARGET_LD) \
    LDFLAGS="$(CONFIGURE_LDFLAGS)" \
#    CPP=$(CONFIGURE_CPP) \
#    CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \
#    PKG_CONFIG_LIBDIR=$(CONFIGURE_PKG_CONFIG_LIBDIR) \17
#    PKG_CONFIG_TOP_BUILD_DIR=$(PKG_CONFIG_TOP_BUILD_DIR) \
    $(AVAHI_TOP)/$(CONFIGURE) --host=arm-linux-androideabi \
    --disable-nls --disable-gtk --disable-gtk3 \
    --disable-dbus --disable-python \
    --disable-xmltoman --with-xml=none \
    --disable-glib --disable-gobject --disable-qt3 --disable-qt4 \
    --disable-gdbm --disable-libdaemon \
    --with-distro=none --disable-core-docs \
    --disable-Werror
    echo "before make file"
    for file in $(AVAHI_BUILT_SOURCES); do \
       rm -f $$file && \
        make -C $$(dirname $$file) $$(basename $$file) ; \
    done

    avahi-configure: avahi-configure-real

    .PHONY: avahi-configure

    CONFIGURE_TARGETS += avahi-configure

    #include all the subdirs...
    #-include $(AVAHI_TOP)/avahi-common/Android.mk
    #-include $(AVAHI_TOP)/avahi-client/Android.mk
    -include $(AVAHI_TOP)/avahi-core/Android.mk
    #-include $(AVAHI_TOP)/avahi-daemon/Android.mk
    #-include $(AVAHI_TOP)/avahi-glib/Android.mk
    #-include $(AVAHI_TOP)/avahi-gobject/Android.mk
    #-include $(AVAHI_TOP)/avahi-utils/Android.mk

#generate libavahi.so and libavahi.a
LOCAL_MODULE    := avahi_static
LOCAL_MODULE_FILENAME := libavahi
-include $(BUILD_STATIC_LIBRARY)

LOCAL_MODULE    := avahi_shared
LOCAL_MODULE_FILENAME := libavahi
-include $(BUILD_SHARED_LIBRARY)
4

3 回答 3

3

您下载的补丁不是最新的。最新的 NDK r8b 包含linux/ipv6.h在早期版本的 NDK 上找不到的文件。不幸的是,这种对 NDK 的更改,尽管很受欢迎,但从未被记录在案。

这意味着您必须socket.c通过删除行来撤消对文件的补丁

67  #ifdef __BIONIC__ 
68  struct in6_pktinfo { 
69      struct in6_addr ipi6_addr; 
70      int ipi6_ifindex; 
71  }; 
72  #endif 
73   

avahi-core/socket.c文件。

于 2012-09-27T10:59:34.713 回答
0

Application.mk使用以下内容创建:

APP_OPTIM := release
APP_PLATFORM := android-7
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI := armeabi armeabi-v7a
APP_MODULES := avahi_static

APP_ABI="armeabi armeabi-v7a"然后在你的ndk-build命令中省略。

于 2012-09-27T10:28:48.700 回答
0
1.tar avahi-0.6.31
2.patch -p1 < 0001-Add-Android-support.patch (http://avahi.org/ticket/354)
patch -p1 < 0002-Add-uninstalled.pc.in-files.patch 

3.cd avahi-0.6.31 ./configure --sysconfdir=/etc --localstatedir=/var make 

4.cd the subdirectories make Android.mk 

then,you will see Android.mk in all the subdirectories.


5.ndk-build V=1 NDK_LOG=2 APP_ABI="armeabi armeabi-v7a"
于 2013-03-14T02:19:21.460 回答