You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在x86_64 Ubuntu下交叉编译iperf-2.0.5到ARM64的配置错误求助

在x86_64 Ubuntu上交叉编译iperf-2.0.5到ARM64的配置问题

已安装交叉编译器:

sudo apt install gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu g++-aarch64-linux-gnu

最初执行的配置命令:

./configure --build=aarch64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --enable-static --disable-shared

得到警告:configure: WARNING: unrecognized options: --enable-static, --disable-shared

执行make时出现编译错误,错误信息如下:

make  all-recursive
make[1]: Entering directory '/home/recherma/Documents/iperf-2.0.5'
Making all in compat
make[2]: Entering directory '/home/recherma/Documents/iperf-2.0.5/compat'
if g++ -DHAVE_CONFIG_H -I. -I. -I..  -I../include -I../include  -Wall -O2  -MT delay.o -MD -MP -MF ".deps/delay.Tpo" -c -o delay.o delay.cpp; \
then mv -f ".deps/delay.Tpo" ".deps/delay.Po"; else rm -f ".deps/delay.Tpo"; exit 1; fi
In file included from /usr/include/c++/9/stdlib.h:36,
                 from ../include/headers.h:78,
                 from ../include/Timestamp.hpp:63,
                 from delay.cpp:53:
/usr/include/c++/9/cstdlib:151:11: error: ‘::malloc’ has not been declared
  151 |   using ::malloc;
      |           ^~~~~~
In file included from ../include/headers.h:78,
                 from ../include/Timestamp.hpp:63,
                 from delay.cpp:53:
/usr/include/c++/9/stdlib.h:65:12: error: ‘std::malloc’ has not been declared
   65 | using std::malloc;
      |            ^~~~~~
In file included from /usr/include/c++/9/cmath:42,
                 from /usr/include/c++/9/math.h:36,
                 from ../include/headers.h:85,
                 from ../include/Timestamp.hpp:63,
                 from delay.cpp:53:
/usr/include/c++/9/bits/cpp_type_traits.h:214:12: error: redefinition of ‘struct std::__is_integer<int>’
  214 |     struct __is_integer<int>
      |            ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/cpp_type_traits.h:138:12: note: previous definition of ‘struct std::__is_integer<int>’
  138 |     struct __is_integer<bool>
      |            ^~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:273: delay.o] Error 1
make[2]: Leaving directory '/home/recherma/Documents/iperf-2.0.5/compat'
make[1]: *** [Makefile:252: all-recursive] Error 1
make[1]: Leaving directory '/home/recherma/Documents/iperf-2.0.5'
make: *** [Makefile:190: all] Error 2

编辑补充:尝试将--host改为aarch64-unknown-linux-gnu,问题依旧,错误完全相同。


正确配置与解决步骤

1. 修正--build和--host参数

交叉编译的参数规则:

  • --build:当前编译机器的架构(你的x86_64 Ubuntu)
  • --host:目标运行机器的架构(ARM64平台)
    之前的参数完全搞反,这是核心问题。

2. 移除不支持的参数

iperf-2.0.5的configure脚本不支持--enable-static和--disable-shared,直接去掉这两个参数即可。

3. 明确指定交叉编译器

配置时必须告诉configure使用ARM64的交叉编译器,避免调用本地x86的gcc/g++:

完整配置命令:

./configure --build=x86_64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++

4. 清理旧产物后重新编译

先彻底清理之前的错误配置和编译文件:

make distclean

再执行上面的configure命令,最后运行make即可正常编译。

补充:静态编译实现(可选)

如果需要生成静态链接的iperf,在configure时添加LDFLAGS参数:

./configure --build=x86_64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ LDFLAGS="-static"

内容的提问来源于stack exchange,提问作者Simon Rechermann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 04:20:31