交叉编译coreutils
Cross-compiling coreutils
我在尝试为 ARM 交叉编译 GNU coreutils(git 克隆 https://git.savannah.gnu.org/git/coreutils.git)时遇到问题。
按照 StackExchange 网络中的其他问答,我完成了以下过程:
设置:
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
Y你没有编译?
我看到它试图在我的 x64 机器上 运行 这个 make-prime-list
,因此出现格式错误。但无论如何它应该用工具链编译...
有什么建议吗?
到cross-compile,你应该只将--host
选项指定给./configure
,你不能将你的cross-compiler指定为CC
和CXX
。 configure
脚本应该做正确的事情,对主机二进制文件使用主机编译器,例如 make-prime-list
,对目标二进制文件使用 cross-compiler...
但是好像没有,所以src/primes.h
无法生成。该文件似乎不是 arch-specific,并且 make clean
不会删除它,因此以下对我有用:
./configure && make
为构建架构构建make-prime-list
,并用它来生成src/primes.h
,然后是
make clean && ./configure --host=arm-linux-gnueabihf && make
到cross-compile目标二进制文件。
我在尝试为 ARM 交叉编译 GNU coreutils(git 克隆 https://git.savannah.gnu.org/git/coreutils.git)时遇到问题。
按照 StackExchange 网络中的其他问答,我完成了以下过程:
设置:
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
Y你没有编译?
我看到它试图在我的 x64 机器上 运行 这个 make-prime-list
,因此出现格式错误。但无论如何它应该用工具链编译...
有什么建议吗?
到cross-compile,你应该只将--host
选项指定给./configure
,你不能将你的cross-compiler指定为CC
和CXX
。 configure
脚本应该做正确的事情,对主机二进制文件使用主机编译器,例如 make-prime-list
,对目标二进制文件使用 cross-compiler...
但是好像没有,所以src/primes.h
无法生成。该文件似乎不是 arch-specific,并且 make clean
不会删除它,因此以下对我有用:
./configure && make
为构建架构构建make-prime-list
,并用它来生成src/primes.h
,然后是
make clean && ./configure --host=arm-linux-gnueabihf && make
到cross-compile目标二进制文件。