使用 Android NDK 工具链交叉编译 Iperf:Iperf 在主机中运行,但不在目标计算机中运行



我正在尝试编译iperf源代码并在Android设备上运行它。我正在使用 ubuntu 服务器来编译代码。我已经下载了iperf源代码以及Android NDK。我使用 make-standalone-toolchain.sh 构建了工具链。然后我将工具链/箱添加到我的路径中。我运行了arm-linux-androideabi-gcc -v以确保它在我的路径上。然后我转到 iperf 源代码并使用以下命令对其进行配置

./configure --host=arm-linux --prefix=$HOMER/iperf_install CC=arm-linux-androideabi-gcc     CXX=arm-linux-androideabi-g++ CFLAGS=-static CXXFLAGS=-static

其中$HOMER是我的当前目录在此之后,我使用了以下命令:

make install

我去了安装文件夹(iperf_install(并转到 bin 并使用 iperf3 运行

./iperf3

我能够在我的 ubuntu 服务器中运行 iperf3,但不能在我的安卓设备上运行。

我在配置时收到以下日志:

checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-androideabi-gcc accepts -g... yes
checking for arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of arm-linux-androideabi-gcc... gcc3
checking for arm-linux-ranlib... no
checking for ranlib... ranlib
configure: WARNING: using cross tools not prefixed with host triplet
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by arm-linux-androideabi-gcc... /local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld
checking if the linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) is GNU ld... yes
checking for /local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld option to reload object files... -r
checking for BSD-compatible nm... nm
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... arm-linux-androideabi-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... yes
checking whether arm-linux-androideabi-g++ accepts -g... yes
checking dependency style of arm-linux-androideabi-g++... gcc3
checking how to run the C++ preprocessor... arm-linux-androideabi-g++ -E
checking for arm-linux-g77... no
checking for arm-linux-xlf... no
checking for arm-linux-f77... no
checking for arm-linux-frt... no
checking for arm-linux-pgf77... no
checking for arm-linux-cf77... no
checking for arm-linux-fort77... no
checking for arm-linux-fl32... no
checking for arm-linux-af77... no
checking for arm-linux-xlf90... no
checking for arm-linux-f90... no
checking for arm-linux-pgf90... no
checking for arm-linux-pghpf... no
checking for arm-linux-epcf90... no
checking for arm-linux-gfortran... no
checking for arm-linux-g95... no
checking for arm-linux-xlf95... no
checking for arm-linux-f95... no
checking for arm-linux-fort... no
checking for arm-linux-ifort... no
checking for arm-linux-ifc... no
checking for arm-linux-efc... no
checking for arm-linux-pgf95... no
checking for arm-linux-lf95... no
checking for arm-linux-ftn... no
checking for g77... g77
checking whether we are using the GNU Fortran 77 compiler... no
checking whether g77 accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse nm output from arm-linux-androideabi-gcc object... ok
checking for objdir... .libs
checking for arm-linux-ar... no
checking for ar... ar
checking for arm-linux-ranlib... ranlib
checking for arm-linux-strip... strip
checking if arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-linux-androideabi-gcc option to produce PIC... -fPIC
checking if arm-linux-androideabi-gcc PIC flag -fPIC works... yes
checking if arm-linux-androideabi-gcc static flag -static works... yes
checking if arm-linux-androideabi-gcc supports -c -o file.o... yes
checking whether the arm-linux-androideabi-gcc linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) supports shared libraries... yes
checking whether -lc should 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... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by arm-linux-androideabi-g++... /local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld
checking if the linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) is GNU ld... yes
checking whether the arm-linux-androideabi-g++ linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) supports shared libraries... yes
checking for arm-linux-androideabi-g++ option to produce PIC... -fPIC
checking if arm-linux-androideabi-g++ PIC flag -fPIC works... yes
checking if arm-linux-androideabi-g++ static flag -static works... yes
checking if arm-linux-androideabi-g++ supports -c -o file.o... yes
checking whether the arm-linux-androideabi-g++ linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g77 option to produce PIC... -fPIC
checking if g77 PIC flag -fPIC works... no
checking if g77 static flag -static works... no
checking if g77 supports -c -o file.o... no
checking whether the g77 linker (/local/mnt/workspace/ssuryade/android-toolchain/arm-linux-androideabi/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking for library containing nanosleep... none required
checking for library containing hstrerror... none required
checking for an ANSI C-conforming const... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/config.h
config.status: src/config.h is unchanged
config.status: executing depfiles commands
ssuryade@hyd-lnxbld13:/local/mnt/workspace/ssuryade/iperf-3.0b5$ ls
AUTHORS  LICENSE   Makefile.am  README         TODO        bootstrap.sh  config.log     configure     cross-me.txt  cscope.out  libtool  tags
INSTALL  Makefile  Makefile.in  RELEASE_NOTES  aclocal.m4  config        config.status  configure.ac  cross_me.txt  examples    src
ssuryade@hyd-lnxbld13:/local/mnt/workspace/ssuryade/iperf-3.0b5$ cat cross_me.txt
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for arm-linux-strip... no
checking for strip... strip
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking for arm-linux-gcc... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for arm-linux-ranlib... no
checking for ranlib... ranlib
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... nm
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... no
checking whether ++ accepts -g... no
checking dependency style of ++... none
checking how to run the C++ preprocessor... /lib/cpp
checking for arm-linux-g77... no
checking for arm-linux-xlf... no
checking for arm-linux-f77... no
checking for arm-linux-frt... no
checking for arm-linux-pgf77... no
checking for arm-linux-cf77... no
checking for arm-linux-fort77... no
checking for arm-linux-fl32... no
checking for arm-linux-af77... no
checking for arm-linux-xlf90... no
checking for arm-linux-f90... no
checking for arm-linux-pgf90... no
checking for arm-linux-pghpf... no
checking for arm-linux-epcf90... no
checking for arm-linux-gfortran... no
checking for arm-linux-g95... no
checking for arm-linux-xlf95... no
checking for arm-linux-f95... no
checking for arm-linux-fort... no
checking for arm-linux-ifort... no
checking for arm-linux-ifc... no
checking for arm-linux-efc... no
checking for arm-linux-pgf95... no
checking for arm-linux-lf95... no
checking for arm-linux-ftn... no
checking for g77... g77
checking whether we are using the GNU Fortran 77 compiler... no
checking whether g77 accepts -g... no
checking the maximum length of command line arguments... 32768
checking command to parse nm output from gcc object... ok
checking for objdir... .libs
checking for arm-linux-ar... no
checking for ar... ar
checking for arm-linux-ranlib... ranlib
checking for arm-linux-strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should 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... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking whether the ++ linker (/usr/bin/ld) supports shared libraries... yes
libtool.m4: error: problem compiling CXX test program
checking for ++ option to produce PIC...
checking if ++ static flag  works... no
checking if ++ supports -c -o file.o... no
checking whether the ++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... unsupported
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g77 option to produce PIC... -fPIC
checking if g77 PIC flag -fPIC works... no
checking if g77 static flag -static works... no
checking if g77 supports -c -o file.o... no
checking whether the g77 linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking for library containing nanosleep... none required
checking for library containing hstrerror... none required
checking for an ANSI C-conforming const... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/config.h
config.status: src/config.h is unchanged
config.status: executing depfiles commands

想知道为什么即使我使用正确的编译器配置它,它也没有使用正确的编译器。使用LDFLAGS也会有所作为吗?会有什么不同?我应该提供本地库的地址,还是应该提供 android 工具链中包含的库的地址?

请帮忙!

你可以按照这个 GitHub 存储库中的 Dockerfile 进行操作,其中包含 Ubuntu 使用 Android SDK/NDK 为 Android 设备编译 iperf/iperf3 的所有必要步骤。

最新更新