交叉编译coreutils

时间:2018-02-21 17:22:02

标签: arm cross-platform gnu-coreutils

我在尝试为ARM交叉编译GNU coreutils( git clone https://git.savannah.gnu.org/git/coreutils.git )时遇到了问题。

在StackExchange网络中的其他Q& As之后,我最终得到了以下过程:

设定:

git clone https://git.savannah.gnu.org/git/coreutils.git
cd coreutils/ && ./bootstrap
[...]

交叉编译:

export CC=/path/to/toolchain/arm-linux-gnueabihf-gcc
export CXX=/path/to/toolchain/arm-linux-gnueabihf-g++

编译:

./configure --host=arm-linux-gnueabihf
[...]
make
  GEN      .version
[...]
  GEN      lib/wchar.h
  GEN      lib/wctype.h
  GEN      src/coreutils.h
  GEN      src/dircolors.h
make src/make-prime-list
make[1]: Entering directory '/media/data/sources/coreutils'
  CC       src/make-prime-list.o
  CCLD     src/make-prime-list
make[1]: Leaving directory '/media/data/sources/coreutils'
  GEN      src/primes.h
/bin/bash: src/make-prime-list: cannot execute binary file: Exec format error
Makefile:14603: recipe for target 'src/primes.h' failed
make: *** [src/primes.h] Error 126

你没有编译? 我看到它试图在我的x64机器上运行此make-prime-list,因此格式错误。但无论如何它应该用工具链编译......

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

要进行交叉编译,您应该只为--host指定./configure选项,不得将交叉编译器指定为CCCXXconfigure脚本应该做正确的事情,使用主机编译器为make-prime-list等主机二进制文件,以及目标二进制文件的交叉编译器......

但似乎没有,因此无法生成src/primes.h。该文件似乎不是特定于拱形的,并且make clean不会将其删除,因此以下内容适用于我:

./configure && make

为构建体系结构构建make-prime-list,并使用它来生成src/primes.h,然后是

make clean && ./configure --host=arm-linux-gnueabihf && make

交叉编译目标二进制文件。

相关问题