5

i need to install iw wireless packages on android 4.1 device. but i don't know how and what is the require version of the packages to install !!

also is it need linux platform to do this or it is enough to build and install on adb shell for android rooting device.

i see this link but when i do it from adb terminal i see that git and some shells not found ??? how to do it ?

it seems no one has any idea ??

Hana90
  • 943
  • 5
  • 17
  • 37
  • Did you try the binary on that page? If you want to compile it from the device itself, it'll be a lot harder. Certainly git is not installed by default. – kabuko Mar 11 '13 at 20:25
  • @kabuko what do you mean by binary ?also if i try to get ubuntu to work on its terminal i need to install android sdk on it, but how does the device will support this feature if i only compile it on the ubuntu machine for android sdk ? – Hana90 Mar 11 '13 at 20:29

1 Answers1

1

While building iw version 3.11 (which has an Android.mk file already), I encountered some issues due to missing/ wrong headers and libraries. Since it has an Android.mk file, the NDK can be used.

In the following I will assume the following:

  • A device image has been built before (the kernel headers and libnl-2 static library should at least be available). I have built CyanogenMod 10 (with kernel 3.0.something) for the i9300, update the paths below to reflect that.
  • The NDK is installed to ~/android/system/ndk.
  • The NDK has appropriate platforms and toolchains installed.

Preparation after extracting iw-3.11.tar.xz and changing my directory in it:

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

The next issue is the netlink library:

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.

Simply creating a link to the android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux breaks other headers badly which will give errors such as:

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

A workaround is to create the linux directory and put a symlink to ~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h in it:

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

Finally patch Android.mk to finish linking to the netlink library:

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

Now the build can be started:

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

It will not complete because netlink/genl/genl.h cannot be found, but the iw binary is available in libs/armeabi!

Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
  • FYI for anyone needing genetlink.h... for whatever reason, as of NDK R10e, it's onlv available under the API level 21 version of the GNU STL. I was using the API level 17 version, so I just copied it over from the other one to my install. – dadude999 Sep 18 '15 at 17:40