IPerf3 execution from Android 7

https://stackoverflow.com/questions/40975003/iperf3-execution-from-android-7-doesnt-work


I found your question and it helped me to build iperf3 for Android, but I reached on same problem.
Are you using build toolchains from Ubuntu repository? If yes, built binaries it will not work on Android 7.0, because they are using an old version of build toolchains. You will need to build the binaries with most recent NDK version. (now is r13b)

How I solved it:
-Putted all iperf3 sources from src folder on jni folder
-Created Android.mk and Application.mk, which I'll post below, on same folder, along with other files.
-Inside jni folder, I ran ndk-build and, voila, all binaries on /libs folder, working even on Android 7.0 (pick the binaries, put on assets folder and implement your strategy to load the correct binary for the right abi, or just get armeabi binary and load into your app)

Tip: iperf3 uses an folder to cache the results which is inaccessible for Android. You'll need to change this folder to work:
https://github.com/esnet/iperf/blob/670c18584bcf7a285f3561eb7ea38cc53600d0ab/src/iperf_api.c#L2621

Android.mk: (I think that is not necessary to put .h files on this script)
http://pastebin.com/fPsn0wsD

Application.mk:
http://pastebin.com/sgSsGNqB

I recommend to use ndk-build to build library to make more easier to build iperf3 for different architectures, like x86.

iperf3  -  Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_CFLAGS += -fPIE
LOCAL_LDFLAGS += -fPIE -pie

LOCAL_MODULE := iperf3
LOCAL_SRC_FILES :=                         cjson.c \
                                           cjson.h \
                                           flowlabel.h \
                                           iperf.h \
                                           iperf_api.c \
                                           iperf_api.h \
                                           iperf_error.c \
                   			               iperf_client_api.c \
                                           iperf_locale.c \
                                           iperf_locale.h \
                                           iperf_server_api.c \
                                           iperf_tcp.c \
                                           iperf_tcp.h \
                                           iperf_udp.c \
                                           iperf_udp.h \
                   			               iperf_sctp.c \
                   	                       iperf_sctp.h \
                                           iperf_util.c \
                                           iperf_util.h \
                                           main.c \
                                           net.c \
                                           net.h \
                   			               portable_endian.h \
                                           queue.h \
                                           tcp_info.c \
                                           tcp_window_size.c \
                                           tcp_window_size.h \
                                           timer.c \
                                           timer.h \
                                           units.c \
                                           units.h \
                                           version.h

include $(BUILD_EXECUTABLE)


iperf3  -  Application.mk:

APP_ABI := all
APP_PLATAFORM := android-16


posted @ 2017-09-17 22:56  张同光  阅读(180)  评论(0编辑  收藏  举报