arm-fsl-linux-gnueabi交叉编译iperf2.0.8

虚拟机 

Linux  6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

arm-fsl-linux-gnueabi版本

gcc version 4.9.3 20150311 (prerelease) (Linaro GCC 4.9-2015.03)

iperf编译

下载后解压 iperf-2.0.8-source.tar.gz 文件,进入 iperf-2.0.8 目录,输入命令配置

sudo ./configure --host=arm-linux-gnueabi CC=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi-gcc CFLAGS=-static CXX=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-gnueabi/arm-fsl-linux-gnueabi-g++ CXXFLAGS=-static

有如下报错:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-gnueabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether the C++ compiler works... no
configure: error: in `/home/jz/Downloads/iperf-2.0.8':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

查看log,发现问题本质为链接库失败。

/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/libexec/arm-fsl-linux-gnueabi/gcc/arm-fsl-linux-gnueabi/4.9.3/re
al-ld: cannot find -lgcc
/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/libexec/arm-fsl-linux-gnueabi/gcc/arm-fsl-linux-gnueabi/4.9.3/re
al-ld: cannot find -lgcc_eh
/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/libexec/arm-fsl-linux-gnueabi/gcc/arm-fsl-linux-gnueabi/4.9.3/re
al-ld: cannot find -lc
collect2: error: ld returned 1 exit status

解决方法

问题本质为编译工具库路径未集成到系统PATH中。

在编译工具链目录找到environment-setup-cortexa7hf-vfp-neon-fsl-linux-gnueabi文件,source一把即可。

 

再通过env查看当前path等信息:

PKG_CONFIG_PATH=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi/usr/lib/pkgconfig
LANGUAGE=zh_CN:en
GDB=arm-fsl-linux-gnueabi-gdb
CCACHE_PATH=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/../x86_64-fslsdk-linux/bin:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-gnueabi:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-uclibc:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-musl:
SDKTARGETSYSROOT=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
CPP=arm-fsl-linux-gnueabi-gcc -E -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
TARGET_PREFIX=arm-fsl-linux-gnueabi-
SUDO_COMMAND=/usr/bin/su
LC_MONETARY=zh_CN.UTF-8
SUDO_USER=jz
CXX=arm-fsl-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types
XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.I9KZB2
OECORE_NATIVE_SYSROOT=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux
LDFLAGS=-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
XDG_CURRENT_DESKTOP=ubuntu:GNOME
KCFLAGS=--sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
OECORE_TARGET_SYSROOT=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
CPPFLAGS=
LD=arm-fsl-linux-gnueabi-ld --sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_IDENTIFICATION=zh_CN.UTF-8
TERM=xterm-256color
PYTHONHOME=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr
LESSOPEN=| /usr/bin/lesspipe %s
USER=root
AR=arm-fsl-linux-gnueabi-ar
ARCH=arm
AS=arm-fsl-linux-gnueabi-as
DISPLAY=:0
SHLVL=1
NM=arm-fsl-linux-gnueabi-nm
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
OECORE_DISTRO_VERSION=2.0
PKG_CONFIG_SYSROOT_DIR=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
OECORE_ACLOCAL_OPTS=-I /opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/share/aclocal
OBJCOPY=arm-fsl-linux-gnueabi-objcopy
LC_TIME=zh_CN.UTF-8
STRIP=arm-fsl-linux-gnueabi-strip
OBJDUMP=arm-fsl-linux-gnueabi-objdump
CONFIG_SITE=/opt/fsl-qoriq/2.0/site-config-cortexa7hf-vfp-neon-fsl-linux-gnueabi
PATH=/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/../x86_64-fslsdk-linux/bin:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-gnueabi:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-uclibc:/opt/fsl-qoriq/2.0/sysroots/x86_64-fslsdk-linux/usr/bin/arm-fsl-linux-musl:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
CC=arm-fsl-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types
SUDO_UID=1000
CROSS_COMPILE=arm-fsl-linux-gnueabi-
MAIL=/var/mail/root
CONFIGURE_FLAGS=--target=arm-fsl-linux-gnueabi --host=arm-fsl-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/opt/fsl-qoriq/2.0/sysroots/cortexa7hf-vfp-neon-fsl-linux-gnueabi
RANLIB=arm-fsl-linux-gnueabi-ranlib
LC_NUMERIC=zh_CN.UTF-8
OLDPWD=/opt/fsl-qoriq/2.0
_=/usr/bin/env

之后在iperf目录中直接执行./configure --host=arm-fsl-linux

make 

make install

在src目录中得到生成的iperf执行文件。

 参考ld问题

mips使用buildroot,交叉静态编译file程序出现ld: cannot find -lz错误解决过程_交叉编译ld :cannot find -lz -lbz2-CSDN博客

posted @ 2023-10-17 14:08  zensi  阅读(229)  评论(0编辑  收藏  举报