将 avahi 编译到 Android NDK 项目中的问题 [英] Problems compiling avahi into Android NDK project

查看:15
本文介绍了将 avahi 编译到 Android NDK 项目中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Over the last few days I've been having a difficult time trying to build avahi into a static or shared library for use with an existing Android NDK project.

We have a few games in the App and Play stores and my task is to get multiplayer working in the Android versions. Specifically the task involves replacing the Bonjour component so that these games can connect to each other via zeroconf.

Research seemed to indicate that avahi is the lib that we're looking for, but at this point I'm open to anything that will work!

I'm hoping that someone here can either help me get avahi compiling or suggest another more appropriate (and easier to install) lib.

Project uses android-ndk-r8b and is being built on OSX 10.7.4 using command line (not eclipse)

Got the latest Avahi source from here: http://www.linuxfromscratch.org/blfs/view/svn/basicnet/avahi.html

homebrewed all the necessary libs to get ./configure to run without errors.

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static --disable-mono --disable-monodoc  --disable-gdbm --disable-libdaemon --disable-nls --disable-gtk --disable-gtk3 --disable-python --disable-qt3 --disable-qt4 --enable-core-docs --with-distro=none

./configure runs with no apparent red flags.

make results in this compile error:

socket.c: In function 'ipv6_pktinfo':
socket.c:271: warning: unused variable 'yes' [-Wunused-variable]
socket.c:270: warning: unused parameter 'fd' [-Wunused-parameter]
socket.c: In function 'avahi_send_dns_packet_ipv6':
socket.c:609: error: 'IPV6_PKTINFO' undeclared (first use in this function)
socket.c:609: error: (Each undeclared identifier is reported only once
socket.c:609: error: for each function it appears in.)
socket.c: In function 'avahi_recv_dns_packet_ipv6':
socket.c:869: error: 'IPV6_HOPLIMIT' undeclared (first use in this function)
socket.c:878: error: 'IPV6_PKTINFO' undeclared (first use in this function)
make[2]: *** [libavahi_core_la-socket.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Figured that it's not building against the android-ndk-r8b libs or finding ipv6.h or something.

Checked my .bash_profile.sh file:

export PATH=/Users/Muy01/Projects/Development/Android/android-sdks/tools/:$PATH
export PATH=/Users/Muy01/Projects/Development/Android/android-sdks/platform-tools/:$PATH
export PATH=/Users/Muy01/Projects/Development/Android/android-ndk-r8b/:$PATH

added --host=arm-linux-androideabi to the ./configure arguments list resulting in this error:

checking host system type... Invalid configuration `arm-linux-androideabi': system `androideabi' not recognized

Couldn't figure out how to get a list of available host system types so changed direction and decided to try and build the static lib via Android.mk file.

Found this post on creating an appropriate Android.mk file: can't compile avahi on android

Realized that I don't have Android.mk files within all the subdirectories.

Researched, downloaded, built, Androgenizer to try and convert all the Makefile.am files into Android.mk files. http://cgit.collabora.com/git/user/derek/androgenizer.git/

Couldn't figure out or find info on how to do that though =/

Decided to try and create my own Android.mk file:

LOCAL_PATH := $(call my-dir)
ROOT_LOCAL_PATH :=$(call my-dir)

#Build avahi into a static lib
include $(CLEAR_VARS)
AVAHI_TOP := $(ROOT_LOCAL_PATH)/../avahi-0.6.31

MY_SOURCES := $(wildcard $(AVAHI_TOP)/avahi-core/*.c*)
MY_SOURCES += $(wildcard $(AVAHI_TOP)/avahi-common/*.c*)
LOCAL_C_INCLUDES := $(AVAHI_TOP)
LOCAL_SRC_FILES := $(MY_SOURCES:$(LOCAL_PATH)%=%)

LOCAL_MODULE    := avahi

include $(BUILD_STATIC_LIBRARY)

Results in compile time errors for avahi-core/iface-linux.c:33:0:

/avahi-0.6.31/avahi-core/iface-linux.h:27:8: Redefinition of 'struct AvahiInterfaceMonitorOSDep'
/avahi-0.6.31/avahi-core/iface.h:46:16: Originally defined here
/avahi-0.6.31/avahi-core/iface-linux.h:33:9: Redeclaration of enumerator 'LIST_IFACE'
/avahi-0.6.31/avahi-core/iface.h:52:9: Previous definition of 'LIST_IFACE' was here
/avahi-0.6.31/avahi-core/iface-linux.h:34:9: Redeclaration of enumerator 'LIST_ADDR'
/avahi-0.6.31/avahi-core/iface.h:53:9: Previous definition of 'LIST_ADDR' was here
/avahi-0.6.31/avahi-core/iface-linux.h:35:9: Redeclaration of enumerator 'LIST_DONE'
/avahi-0.6.31/avahi-core/iface.h:54:9: Previous definition of 'LIST_DONE' was here
/jni//../avahi-0.6.31/avahi-core/iface-linux.c: In function 'netlink_callback':

And now I'm pretty much stuck.

I tried #if 0'ing out the iface-linux.c and h files resulting in a cascading slew of other errors, so prob a bad idea.

Thinking that it may be something I've done wrong with the ./configure command? Perhaps an issue with my Android.mk file?

I figure this must be something that quite a few developers are dealing with so I'm probably missing something because I can't seem to find any good information via google.

Any help would be much appreciated! I've sent this out to the avhi mailing list as well, if I get a response there I will post here for posterity.

Thanks, Chris

解决方案

I'll follow up here with the solution that worked for me.

My solution was to use JMDNS instead of Avahi.

There's not much traffic on the Avahi mailing list.

JMDNS has working examples available. JMDNS took me about 4 hours to set up within my NDK environment and about a day to work out some "kinks."

这篇关于将 avahi 编译到 Android NDK 项目中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆