compile and build “iw” for android 4.1 device? - android

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 ??

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!

Related

How get fast pixel color on Android use ScreenshotClient?

I want get color pixel use an binary file with params x and y. The screencap is very slow. Using a virtual display also does not give the desired result.
I found and code screencap, and good project: sji-android-screen-capture-old and sji-android-screen-capture-new.
But those solutions don't run in my phone. If run get-raw-image.cpp after compile get-raw-image.cpp I get errors:
WARNING: linker: /data/local/tmp/get-raw-image-4.1.2: unused DT entry: type 0xf arg 0x21d
CANNOT LINK EXECUTABLE: cannot locate symbol "_ZN7android16ScreenshotClient6updateERKNS_2spINS_7IBinderEEE".
For compilation, I use the following settings:
/root/arm/bin/arm-linux-androideabi-clang -pie get-raw-image.cpp -lsupc++ libgui.so -o /get-raw-image-4.1.2 -Xlinker -rpath=/system/lib -DTARGET_JB
If run Android-fast-screen-capture:
/root/arm/bin/arm-linux-androideabi-clang -pie /screen/ascreencap.cpp -o /test -std=c++11
I had errors:
In file included from /screen/ascreencap.cpp:8:
In file included from /root/arm/bin/../sysroot/usr/include/binder/IPCThreadState.h:21:
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:86:11: error: unknown type
name 'binder_size_t'
const binder_size_t* objects() const;
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:220:47: error: unknown type
name 'binder_size_t'
const binder_size_t* objects, si...
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:228:51: error: unknown type
name 'binder_size_t'
const binder_size_t* objects...
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:264:5: error: unknown type
name 'binder_size_t'
binder_size_t* mObjects;
^
In file included from /screen/ascreencap.cpp:8:
/root/arm/bin/../sysroot/usr/include/binder/IPCThreadState.h:114:50: error:
unknown type name 'binder_size_t'
const binder_size_t* objects...
^
5 errors generated.
Also I found the question how-to-use-screenshotclient-in-my-android-application but I don't understand how set link to ScreenshotClient, so that the compiler does not return an error.
My phone is Homtom HT16:
Processor : ARMv7 Processor rev 3 (v7l)
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 26.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
Maybe someone will tell you how to compile the code under my phone or which way to go to solve the problem.
I solved my problem.
Steps:
1) Copy need library from android phone (libgui.so, libui.so, libcutils.so, libutils.so, libbinder.so).
2) Add in sys_root (when save ndk lib code files from Android Android 6_r1 libs: utils, cutils, system, log, hardware, system, ports, core, include/gui, include/ui, include/binder). You can run this code for find your system root:
echo "#include <bogus.h> int main(){}" > t.c; GCC_OR_CLANG_BINARY_LINK -v t.c; rm t.c
Erors printed all paths where compiler search include files.
or use --sysroot=YOUR_PATH for set your path.
3) Add flags -Wl,--unresolved-symbols=ignore-all for ignore errors and --target=armv7-none-linux-androideabi23 (23 or other) for set target version.
Full my clang command:
/Users/macbookair/Documents/test/bin/clang -fPIE -pie fast-screen-capture.cpp *.so -o ./screencap --target=armv7-none-linux-androideabi23 -Wl,--unresolved-symbols=ignore-all -s
Successes!

Compilation Python 3.6.5 static binary for arm32 fail

I'm trying, on Debian 9.4 x64, to compiling static Python binaries for arm32.
I have initialy:
downloaded the "Gzipped source tarball" source file from:
https://www.python.org/downloads/release/python-365/
extracted source files in: /python3.6.5/
downloaded and extract "binutils-gold-2.29.1-16.1.armv7hl.rpm" by cmd line:
rpm -qlp /python3.6.5/binutils-gold-2.29.1-16.1.armv7hl.rpm
try to compile the binary with this following command:
./configure --build=arm --prefix="$PWD"/out LDFLAGS="-static -static-libgcc -Wl,--unresolved-symbols=ignore-all -Wl,--export-dynamic" CPPFLAGS=-static CXXFLAGS=-static CFLAGS="-Os -static" LDFLAGS=-static LD=ld.gold
And i get this errors:
/usr/bin/ld: BFD assertion (GNU Binutils for Debian) 2.28 as failed ../../bfd/elflink.c:14098
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.28 internal error, aborting at ../../bfd/elf64-x86-64.c:6137 in elf_x86_64_finish_dynamic_symbol
/usr/bin/ld: Thanks to report this anomaly.
collect2: error: ld returned 1 exit status
Makefile:561 : the recipe for the "python" target has failed
-make: *** [python] Error 1
I'm trying to find how i could fix this error, but unfortunatly the support webpage on Python website isn't helpfull (https://wiki.python.org/moin/BuildStatically).
Finally, I would like to compile Python 3.6.5 for all processor platforms on which Android can run (arm32, aarm64, x86_x64, mips, mipsx64,...), to ultimately get a single binary file (i will repeat tasks for all other archs when i will have done with arm32).
So one file for each architectures cited, not multiple files/folders.
In a static way to avoid any dependencies with external libraries.
I chose to carry out the build operations, but if other less hazardous and simpler solutions exist i am taker.
NB: all cmd line has been made through LXTerminal on root session by default.
Thanks by advance for help.

NDK build error: "fatal error: stdint.h: No such file or directory" on Mac Os X

I use the following build command to build OpenH264 project.
make OS=android ARCH=arm64 NDKROOT=~/Library/Android/android-ndk-r10d/ TARGET=android-12
But i got the following error:
/Users/jerikc/Library/Android/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9/include-fixed/limits.h:168:61: error: no include path in which to search for limits.h
#include_next <limits.h> /* recurse down to the real one */
^
In file included from ./codec/common/inc/typedefs.h:48:0,
from ./codec/common/inc/wels_common_defs.h:37,
from codec/common/src/common_tables.cpp:33:
/Users/jerikc/Library/Android/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
You request target platform 12, which does not support arm64. The lowest TARGET for this architecture is android-21.
There is probably some glitch in the script, and we must set the platform twice in the build command:
make OS=android ARCH=arm64 TARGET=android-21 NDKLEVEL=21
Make sure that NDKROOT and PATH are set correctly.

Android NDK - Building Limbo Android returns fatal error: config.h: No such file or directory

I'm trying to rebuild Limbo Android. I'm on Linux Mint.
All I changed was android-config.mak NDK_ROOT, exported variables NDK_ROOT. I've also exported NDK_MODULE_PATH to /home/pathtoandroidndk/sources, as per README instructions.
From terminal I do cd limbo-android/jni and then make.
Building returns this error:
jni/glib/glib/./libcharset/localcharset.c:22:20: fatal error: config.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs-debug/glib-2.0/./libcharset/localcharset.o] Error 1
make: Leaving directory `/home/me/limbo-android'
I've tried modifing Android.mk following instructions from Android NDK - Additional Include Directories and Unable to find header files - Android NDK, without success.
I came to conclusion that each module inside limbo-android needs it's own config.h file, while libcharset does not have one.
How do I solve this error? Is there a generic config.h (the one from NDK maybe?)
NOTE: I can build it without any problems on Windows 8.1 using mingw.

libpcap static linking errors compiling with ndk toolchains for android

I have downloaded the libpcap in external folder from android source code using the Git and
repo. I used the toolcains of ndk (android-ndk-r5b) to compile the library following these
steps:
./configure --prefix=path-to-android-src/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
make clean
make
make install
and then a file libpcap.a is produced.
I have make a simple sniffer using libpcap (sniffer.c). When I try to compile it, these errors occur:
agcc sniffer.c libpcap.a
sniffer.c:9:18: error: pcap.h: No such file or directory
sniffer.c:19: warning: 'struct pcap_pkthdr' declared inside parameter list
sniffer.c:19: warning: its scope is only this definition or declaration, which is probably not what you want
sniffer.c: In function 'processPacket':
sniffer.c:23: warning: incompatible implicit declaration of built-in function 'printf'
sniffer.c:24: error: dereferencing pointer to incomplete type
sniffer.c:26: error: dereferencing pointer to incomplete type
sniffer.c:33: error: dereferencing pointer to incomplete type
sniffer.c: In function 'main':
sniffer.c:45: error: 'pcap_t' undeclared (first use in this function)
sniffer.c:45: error: (Each undeclared identifier is reported only once
sniffer.c:45: error: for each function it appears in.)
sniffer.c:45: error: 'descr' undeclared (first use in this function)
sniffer.c:46: error: 'PCAP_ERRBUF_SIZE' undeclared (first use in this function)
sniffer.c:62: warning: incompatible implicit declaration of built-in function 'printf'
sniffer.c:66: warning: incompatible implicit declaration of built-in function 'fprintf'
sniffer.c:66: error: 'stderr' undeclared (first use in this function)
sniffer.c:72: warning: incompatible implicit declaration of built-in function 'fprintf'
when I try to produce the object code in advance:
agcc -c sniffer.o sniffer.c
the same errors occured.
Can someone explain me how to solve this problem?
here is the alias of agcc I use in bashrc file:
./configure --prefix=/home/petsas/projects/mobile-attacks/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/
Also, I have attached a file with the outputs of the commands above: configure, make and make install.
(I put the errors in code style because there were errors of alignment)
Thank you in advance!
-- update --
I used the options -I and -L to specify the include and library files, and these errors are gone now..
Here is my new error log:
agcc --static -I /home/petsas/projects/mobile-attacks/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/include -L /home/petsas/projects/mobile-attacks/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/lib -o sniffer sniffer.c libpcap.a
/home/petsas/projects/mobile-attacks/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: libpcap.a(pcap-linux.o): Relocations in generic ELF (EM: 3)
/home/petsas/projects/mobile-attacks/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: libpcap.a(pcap-linux.o): Relocations in generic ELF (EM: 3)
/home/petsas/projects/mobile-attacks/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: libpcap.a(pcap-linux.o): Relocations in generic ELF (EM: 3)
libpcap.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
any ideas?
Heading
I couldn't find the solution following the way I describe above, but I made it through
writing a Android.mdk file and by using the ndk-build of android NDK.
I put the libpcap direcotry into the android-ndk-r5b/samples, I modified a bit the Android.mdk
and the structure of the direcotry, so as to look like the other ones inside the samples dir and
I used the ndk-build command inside the android-ndk-r5b direcory:
ndk-build -C samples/android-ndk-r5b
All worked fine! I was able to produce a libpicap.so file, and put it in the phone using the
commands:
in android (phone):
$ su
# mount -o,rw remount /dev/block/mtdblock4 /system/lib
in my Desktop:
$ adb push libpcap.so /system/lib/
I made a simple sniffer, I compiled and linked with the libpcap.so and works perfectly in
my HTC Hero! ;)

Categories

Resources