为android 4.1设备编译并构建“iw”?

时间:2013-03-11 17:51:50

标签: android linux linux-kernel android-wifi android-wireless

我需要在Android 4.1设备上安装iw无线软件包。但我不知道如何以及要安装的软件包的要求版本是什么!!

也需要linux平台才能做到这一点,或者足以在Android root设备的adb shell上构建和安装。

我看到这个 link但是当我从adb终端这样做时,我看到git和一些shell没有找到???怎么做?

似乎没有人有任何想法?

1 个答案:

答案 0 :(得分:1)

在构建iw 3.11版本(已经安装了Android.mk文件)时,由于缺少/错误的标题和库,我遇到了一些问题。由于它有一个Android.mk文件,因此可以使用NDK。

以下我将假设以下内容:

  • 之前已经构建了设备映像(内核头文件和libnl-2静态库至少应该可用)。我为i9300构建了CyanogenMod 10(内核3.0.something),更新下面的路径以反映这一点。
  • NDK已安装到~/android/system/ndk
  • NDK安装了适当的平台和工具链。

提取iw-3.11.tar.xz并更改其中的目录后的准备工作:

ln -s . jni
ln -nsv ~/android/system/external ./

下一期是netlink库:

In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
                 from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:27:29: fatal error: linux/genetlink.h: No such file or directory.

只需创建指向android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux的链接就会严重打破其他标题,这会导致错误,例如:

Compile thumb  : iw <= iw.c
In file included from /home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/net/if.h:28:0,
                 from /tmp/and/iw/jni/iw.c:10:
/tmp/and/iw/jni/linux/if.h:178:19: error: field 'ifru_addr' has incomplete type
/tmp/and/iw/jni/linux/if.h:179:19: error: field 'ifru_dstaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:180:19: error: field 'ifru_broadaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:181:19: error: field 'ifru_netmask' has incomplete type
/tmp/and/iw/jni/linux/if.h:182:20: error: field 'ifru_hwaddr' has incomplete type
In file included from external/libnl-headers/netlink/netlink.h:20:0,
                 from external/libnl-headers/netlink/genl/genl.h:15,
                 from /tmp/and/iw/jni/iw.c:17:
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: 'struct msghdr' declared inside parameter list [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:75:38: warning: 'struct msghdr' declared inside parameter list [enabled by default]
In file included from external/libnl-headers/netlink/netlink.h:25:0,
                 from external/libnl-headers/netlink/genl/genl.h:15,
                 from /tmp/and/iw/jni/iw.c:17:
/tmp/and/iw/jni/linux/netlink.h:33:2: error: unknown type name 'sa_family_t'
In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
                 from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:51:16: warning: 'struct msghdr' declared inside parameter list [enabled by default]
external/libnl-headers/netlink/netlink.h:54:19: warning: 'struct iovec' declared inside parameter list [enabled by default]
make: *** [/tmp/and/iw/obj/local/armeabi/objs/iw/iw.o] Error 1

解决方法是创建linux目录并在其中添加符号链接到~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h

mkdir -p linux
ln -svn ~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h linux/

最后修补Android.mk以完成链接到netlink库:

sed "/LOCAL_LDFLAGS/s#\$# -L$HOME/android/system/out/target/product/i9300/obj/STATIC_LIBRARIES/libnl_2_intermediates -lnl_2#" -i Android.mk

现在可以开始构建:

NDK_PROJECT_PATH=$PWD ~/android/system/ndk/ndk-build TARGET_PLATFORM=android-14

它无法完成,因为无法找到netlink / genl / genl.h,但是iw 二进制文件在libs / armeabi中可用!