一、参考资料
Linux下iperf3移植到arm下测试100M网口-CSDN博客
Iperf3移植到ARM Linux及使用教程-CSDN博客
二、准备工作
1. 编译环境
- 宿主机:Ubuntu 20.04.6 LTS
- Host:ARM32位
- 交叉编译器:
arm-linux-gnueabihf-gcc-11.1.0
2. 设置交叉编译工具链
在交叉编译之前,需要设置交叉编译工具链的环境变量。
exportPATH=/path/to/toolchains/arm-linux-gnueabihf/bin:$PATH3. apt安装iperf3
在宿主机中直接安装iperf3。
sudoapt-getinstalliperf3# iperf3(推荐)sudoapt-getinstalliperf# iperf2三、交叉编译iperf3
1. 下载源码
下载 iperf:https://downloads.es.net/pub/iperf/
iPerf - Download iPerf3 and original iPerf pre-compiled binaries
下载并解压源码。
tar-xvzfiperf-3.18.tar.gzcdiperf-3.18mkdirarm32_install2. 生成 configure 配置
./configure\--prefix=/path/to/iperf-3.18/arm32_install\--host=arm-linux-gnueabihf\--enable-shared\--enable-static输出示例:
yoyo@yoyo:~/360Downloads/iperf-3.18$ ./configure\>--prefix=/path/to/iperf-3.18/arm32_install\>--host=arm-linux-gnueabihf\>--enable-shared\>--enable-static checkingfora BSD-compatible install... /usr/bin/install-cchecking whethersleepsupports fractional seconds...yeschecking filesystem timestamp resolution...0.01checking whether build environment is sane...yescheckingforarm-linux-gnueabihf-strip... arm-linux-gnueabihf-strip checkingfora race-freemkdir-p... /usr/bin/mkdir-pcheckingforgawk... no checkingformawk... mawk checking whethermakesets$(MAKE)...yeschecking whethermakesupports nested variables...yescheckingxargs-nworks...yeschecking build system type... x86_64-pc-linux-gnu checkinghostsystem type... arm-unknown-linux-gnueabihf checking how to print strings...printfchecking whethermakesupports the include directive...yes(GNU style)checkingforarm-linux-gnueabihf-gcc... arm-linux-gnueabihf-gcc checking whether the C compiler works...yescheckingforC compiler default outputfilename... a.out checkingforsuffix of executables... checking whether we are cross compiling...yescheckingforsuffix of object files... o checking whether the compiler supports GNU C...yeschecking whether arm-linux-gnueabihf-gcc accepts -g...yescheckingforarm-linux-gnueabihf-gcc option toenableC11 features... none needed checking whether arm-linux-gnueabihf-gcc understands-cand-otogether...yeschecking dependency style of arm-linux-gnueabihf-gcc... gcc3 checkingforasedthat does not truncate output... /usr/bin/sed checkingforgrepthat handles long lines and -e... /usr/bin/grep checkingforegrep... /usr/bin/grep-Echeckingforfgrep... /usr/bin/grep-Fcheckingforld used by arm-linux-gnueabihf-gcc... /path/to/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld checkingifthe linker(/path/to/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld)is GNU ld...yescheckingforBSD- or MS-compatible name lister(nm)... /path/to/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm-Bchecking the name lister(/path/to/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm -B)interface... BSD nm checking whetherln-sworks...yeschecking the maximum length ofcommandline arguments...1572864checking how to convert x86_64-pc-linux-gnufilenames to arm-unknown-linux-gnueabihf format... func_convert_file_noop checking how to convert x86_64-pc-linux-gnufilenames to toolchain format... func_convert_file_noop checkingfor/path/to/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld option to reload object files...-rcheckingforfile...filecheckingforarm-linux-gnueabihf-objdump... arm-linux-gnueabihf-objdump checking how to recognize dependent libraries... pass_all checkingforarm-linux-gnueabihf-dlltool... no checkingfordlltool... no checking how to associate runtime andlinklibraries...printf%s\n checkingforarm-linux-gnueabihf-ranlib... arm-linux-gnueabihf-ranlib checkingforarm-linux-gnueabihf-ar... arm-linux-gnueabihf-ar checkingforarchiver @FILE support... @ checkingforarm-linux-gnueabihf-strip...(cached)arm-linux-gnueabihf-strip checkingcommandto parse /path/to/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm-Boutput from arm-linux-gnueabihf-gcc object... ok checkingforsysroot... /path/to/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/libc checkingfora working dd... /usr/bin/dd checking how to truncate binary pipes... /usr/bin/ddbs=4096count=1checkingforarm-linux-gnueabihf-mt... no checkingformt... mt configure: WARNING: using cross tools not prefixed withhosttriplet checkingifmt is a manifest tool... no checkingforstdio.h...yescheckingforstdlib.h...yescheckingforstring.h...yescheckingforinttypes.h...yescheckingforstdint.h...yescheckingforstrings.h...yescheckingforsys/stat.h...yescheckingforsys/types.h...yescheckingforunistd.h...yescheckingfordlfcn.h...yescheckingforobjdir... .libs checkingifarm-linux-gnueabihf-gcc supports -fno-rtti -fno-exceptions... no checkingforarm-linux-gnueabihf-gcc option to produce PIC...-fPIC-DPICcheckingifarm-linux-gnueabihf-gcc PIC flag-fPIC-DPICworks...yescheckingifarm-linux-gnueabihf-gcc static flag-staticworks...yescheckingifarm-linux-gnueabihf-gcc supports-c-ofile.o...yescheckingifarm-linux-gnueabihf-gcc supports-c-ofile.o...(cached)yeschecking whether the arm-linux-gnueabihf-gcc linker(/path/to/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld)supports shared libraries...yeschecking whether-lcshould be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible...yescheckingiflibtool supports shared libraries...yeschecking whether to build shared libraries...yeschecking whether to build static libraries...yeschecking whether toenablemaintainer-specific portions of Makefiles... no checkingforarm-linux-gnueabihf-gcc...(cached)arm-linux-gnueabihf-gcc checking whether the compiler supports GNU C...(cached)yeschecking whether arm-linux-gnueabihf-gcc accepts -g...(cached)yescheckingforarm-linux-gnueabihf-gcc option toenableC11 features...(cached)none needed checking whether arm-linux-gnueabihf-gcc understands-cand-otogether...(cached)yeschecking dependency style of arm-linux-gnueabihf-gcc...(cached)gcc3 checking whetherln-sworks...yescheckingforlibrary containing floor...-lmcheckingforlibrary containing socket... none required checkingforlibrary containing inet_ntop... none required checkingforan ANSI C-conforming const...yeschecking how to run the C preprocessor... arm-linux-gnueabihf-gcc-Echeckingforegrep-e...(cached)/usr/bin/grep-Echecking whether arm-linux-gnueabihf-gcc is Clang... no checking whether pthreads work with"-pthread"and"-lpthread"...yescheckingforjoinable pthread attribute... PTHREAD_CREATE_JOINABLE checking whethermorespecial flags are requiredforpthreads... no checkingforPTHREAD_PRIO_INHERIT...yescheckingforstdatomic.h...yeschecking whether libatomic is required... no checkingforpoll.h...yescheckingforlinux/tcp.h...yescheckingforsys/socket.h...yescheckingfornetinet/sctp.h... no checkingforendian.h...yescheckingforarm-linux-gnueabihf-pkg-config... no checkingforpkg-config... pkg-config checkingforinclude/openssl/ssl.hin/usr/local/ssl... no checkingforinclude/openssl/ssl.hin/usr/lib/ssl... no checkingforinclude/openssl/ssl.hin/usr/ssl... no checkingforinclude/openssl/ssl.hin/usr/pkg... no checkingforinclude/openssl/ssl.hin/usr/local... no checkingforinclude/openssl/ssl.hin/usr... no checking whether compiling and linking against OpenSSL works... no checking TCP_CONGESTION socket option...yeschecking TCP_USER_TIMEOUT socket option...yeschecking IPv6 flowlabel support...yescheckingforcpuset_setaffinity... no checkingforsched_setaffinity...yescheckingforSetProcessAffinityMask... no checkingfordaemon...yescheckingforsendfile...yescheckingforgetline...yeschecking SO_MAX_PACING_RATE socket option...yeschecking SO_BINDTODEVICE socket option...yeschecking IP_MTU_DISCOVER socket option...yeschecking IP_DONTFRAG socket option... no checking IP_DONTFRAGMENT socket option... no checking any kind of DF socket option...yescheckingforstruct tcp_info.tcpi_snd_wnd... no checkingforlibrary containing clock_gettime... none required checkingforclock_gettime...yescheckingforlibrary containing nanosleep... none required checkingfornanosleep...yescheckingforlibrary containing clock_nanosleep... none required checkingforclock_nanosleep...yeschecking that generated files are newer than configure...doneconfigure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating src/version.h config.status: creating examples/Makefile config.status: creating iperf3.spec config.status: creating src/iperf_config.h config.status: executing depfiles commands config.status: executing libtool commands3. 编译安装
make-j8makeinstallmake编译:
yoyo@yoyo:~/360Downloads/iperf-3.18$make-j8Making allinsrc make[1]: Entering directory'/path/to/iperf-3.18/src'makeall-am make[2]: Entering directory'/path/to/iperf-3.18/src'CC iperf3-main.o CC cjson.lo CC iperf_api.lo CC iperf_error.lo CC iperf_auth.lo CC iperf_locale.lo CC iperf_client_api.lo CC iperf_server_api.lo CC iperf_tcp.lo CC iperf_udp.lo CC iperf_sctp.lo CC iperf_util.lo CC iperf_time.lo CC iperf_pthread.lo CC dscp.lo CC net.lo CC tcp_info.lo CC timer.lo CC units.lo CC t_timer-t_timer.o CC t_units-t_units.o CC t_uuid-t_uuid.o CC t_api-t_api.o CC t_auth-t_auth.o CCLD libiperf.la CCLD t_timer CCLD iperf3 CCLD t_uuid CCLD t_units CCLD t_api CCLD t_auth make[2]: Leaving directory'/path/to/iperf-3.18/src'make[1]: Leaving directory'/path/to/iperf-3.18/src'Making allinexamples make[1]: Entering directory'/path/to/iperf-3.18/examples'CC mic-mic.o CC mis-mis.o CCLD mis CCLD mic make[1]: Leaving directory'/path/to/iperf-3.18/examples'make[1]: Entering directory'/path/to/iperf-3.18'make[1]: Nothing to bedonefor'all-am'.make[1]: Leaving directory'/path/to/iperf-3.18'make install安装:
yoyo@yoyo:~/360Downloads/iperf-3.18$makeinstallMakinginstallinsrc make[1]: Entering directory'/path/to/iperf-3.18/src'make[2]: Entering directory'/path/to/iperf-3.18/src'/usr/bin/mkdir-p'/path/to/iperf-3.18/arm32_install/lib'/bin/bash../libtool--mode=install /usr/bin/install-clibiperf.la'/path/to/iperf-3.18/arm32_install/lib'libtool: install: /usr/bin/install-c.libs/libiperf.so.0.0.0 /path/to/iperf-3.18/arm32_install/lib/libiperf.so.0.0.0 libtool: install:(cd /path/to/iperf-3.18/arm32_install/lib&&{ln-s-flibiperf.so.0.0.0 libiperf.so.0||{rm-flibiperf.so.0&&ln-slibiperf.so.0.0.0 libiperf.so.0;};})libtool: install:(cd /path/to/iperf-3.18/arm32_install/lib&&{ln-s-flibiperf.so.0.0.0 libiperf.so||{rm-flibiperf.so&&ln-slibiperf.so.0.0.0 libiperf.so;};})libtool: install: /usr/bin/install-c.libs/libiperf.lai /path/to/iperf-3.18/arm32_install/lib/libiperf.la libtool: install: /usr/bin/install-c.libs/libiperf.a /path/to/iperf-3.18/arm32_install/lib/libiperf.a libtool: install:chmod644/path/to/iperf-3.18/arm32_install/lib/libiperf.a libtool: install: arm-linux-gnueabihf-ranlib /path/to/iperf-3.18/arm32_install/lib/libiperf.a libtool: finish:PATH="/path/to/toolchains/arm-linux-gnueabihf/bin:/path/to/cmake-3.31.3-linux-x86_64/bin:/home/yoyo/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin"ldconfig-n/path/to/iperf-3.18/arm32_install/lib ---------------------------------------------------------------------- Libraries have been installed in: /path/to/iperf-3.18/arm32_install/lib If you ever happen to want tolinkagainst installed librariesina given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the'-LLIBDIR'flag during linking anddoat least one of the following: -addLIBDIR to the'LD_LIBRARY_PATH'environment variable during execution -addLIBDIR to the'LD_RUN_PATH'environment variable during linking - use the'-Wl,-rpath -Wl,LIBDIR'linker flag - have your system administratoraddLIBDIR to'/etc/ld.so.conf'See any operating system documentation about shared librariesformoreinformation, such as the ld(1)and ld.so(8)manual pages. ---------------------------------------------------------------------- /usr/bin/mkdir-p'/path/to/iperf-3.18/arm32_install/bin'/bin/bash../libtool--mode=install /usr/bin/install-ciperf3'/path/to/iperf-3.18/arm32_install/bin'libtool: install: /usr/bin/install-c.libs/iperf3 /path/to/iperf-3.18/arm32_install/bin/iperf3 /usr/bin/mkdir-p'/path/to/iperf-3.18/arm32_install/include'/usr/bin/install-c-m644iperf_api.h'/path/to/iperf-3.18/arm32_install/include'/usr/bin/mkdir-p'/path/to/iperf-3.18/arm32_install/share/man/man1'/usr/bin/install-c-m644iperf3.1'/path/to/iperf-3.18/arm32_install/share/man/man1'/usr/bin/mkdir-p'/path/to/iperf-3.18/arm32_install/share/man/man3'/usr/bin/install-c-m644libiperf.3'/path/to/iperf-3.18/arm32_install/share/man/man3'make[2]: Leaving directory'/path/to/iperf-3.18/src'make[1]: Leaving directory'/path/to/iperf-3.18/src'Makinginstallinexamples make[1]: Entering directory'/path/to/iperf-3.18/examples'make[2]: Entering directory'/path/to/iperf-3.18/examples'make[2]: Nothing to bedonefor'install-exec-am'.make[2]: Nothing to bedonefor'install-data-am'.make[2]: Leaving directory'/path/to/iperf-3.18/examples'make[1]: Leaving directory'/path/to/iperf-3.18/examples'make[1]: Entering directory'/path/to/iperf-3.18'make[2]: Entering directory'/path/to/iperf-3.18'make[2]: Nothing to bedonefor'install-exec-am'.make[2]: Nothing to bedonefor'install-data-am'.make[2]: Leaving directory'/path/to/iperf-3.18'make[1]: Leaving directory'/path/to/iperf-3.18'4. 移植到开发板
将编译好的文件,拷贝到开发板。
# 拷贝libcp-r./arm32_install/lib/ /usr/local/iperf3/# 拷贝bincp-r./arm32_install/bin/ /usr/local/iperf3/