
一、参考资料Linux下iperf3移植到arm下测试100M网口-CSDN博客Iperf3移植到ARM Linux及使用教程-CSDN博客二、准备工作1. 编译环境宿主机Ubuntu 20.04.6 LTSHostARM32位交叉编译器arm-linux-gnueabihf-gcc-11.1.02. 设置交叉编译工具链在交叉编译之前需要设置交叉编译工具链的环境变量。exportPATH/path/to/toolchains/arm-linux-gnueabihf/bin:$PATH3. apt安装iperf3在宿主机中直接安装iperf3。sudoapt-getinstalliperf3# iperf3推荐sudoapt-getinstalliperf# iperf2三、交叉编译iperf31. 下载源码下载 iperfhttps://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\--hostarm-linux-gnueabihf\--enable-shared\--enable-static输出示例yoyoyoyo:~/360Downloads/iperf-3.18$ ./configure\--prefix/path/to/iperf-3.18/arm32_install\--hostarm-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/ddbs4096count1checkingforarm-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-pthreadand-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编译yoyoyoyo:~/360Downloads/iperf-3.18$make-j8Making allinsrc make[1]: Entering directory/path/to/iperf-3.18/srcmakeall-am make[2]: Entering directory/path/to/iperf-3.18/srcCC 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/srcmake[1]: Leaving directory/path/to/iperf-3.18/srcMaking allinexamples make[1]: Entering directory/path/to/iperf-3.18/examplesCC mic-mic.o CC mis-mis.o CCLD mis CCLD mic make[1]: Leaving directory/path/to/iperf-3.18/examplesmake[1]: Entering directory/path/to/iperf-3.18make[1]: Nothing to bedoneforall-am.make[1]: Leaving directory/path/to/iperf-3.18make install安装yoyoyoyo:~/360Downloads/iperf-3.18$makeinstallMakinginstallinsrc make[1]: Entering directory/path/to/iperf-3.18/srcmake[2]: Entering directory/path/to/iperf-3.18/src/usr/bin/mkdir-p/path/to/iperf-3.18/arm32_install/lib/bin/bash../libtool--modeinstall /usr/bin/install-clibiperf.la/path/to/iperf-3.18/arm32_install/liblibtool: 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.0ln-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.soln-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:/sbinldconfig-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-LLIBDIRflag during linking anddoat least one of the following: -addLIBDIR to theLD_LIBRARY_PATHenvironment variable during execution -addLIBDIR to theLD_RUN_PATHenvironment variable during linking - use the-Wl,-rpath -Wl,LIBDIRlinker flag - have your system administratoraddLIBDIR to/etc/ld.so.confSee 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--modeinstall /usr/bin/install-ciperf3/path/to/iperf-3.18/arm32_install/binlibtool: 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/man3make[2]: Leaving directory/path/to/iperf-3.18/srcmake[1]: Leaving directory/path/to/iperf-3.18/srcMakinginstallinexamples make[1]: Entering directory/path/to/iperf-3.18/examplesmake[2]: Entering directory/path/to/iperf-3.18/examplesmake[2]: Nothing to bedoneforinstall-exec-am.make[2]: Nothing to bedoneforinstall-data-am.make[2]: Leaving directory/path/to/iperf-3.18/examplesmake[1]: Leaving directory/path/to/iperf-3.18/examplesmake[1]: Entering directory/path/to/iperf-3.18make[2]: Entering directory/path/to/iperf-3.18make[2]: Nothing to bedoneforinstall-exec-am.make[2]: Nothing to bedoneforinstall-data-am.make[2]: Leaving directory/path/to/iperf-3.18make[1]: Leaving directory/path/to/iperf-3.184. 移植到开发板将编译好的文件拷贝到开发板。# 拷贝libcp-r./arm32_install/lib/ /usr/local/iperf3/# 拷贝bincp-r./arm32_install/bin/ /usr/local/iperf3/