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 @   张同光  阅读(182)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示