gpt4 book ai didi

python - 为 ARM 交叉编译 Python 时出错

转载 作者:太空狗 更新时间:2023-10-29 20:31:32 28 4
gpt4 key购买 nike

我正在尝试为 ARM 编译 Python(版本 3.1.3),遵循 this guide .

这些是我发出的命令(在 Ubuntu 12 上):

CC=arm-linux-gnueabi-gcc CXX=arm-linux-gnueabi-g++ AR=arm-linux-gnueabi-ar RANLIB=arm-linux-gnueabi-ranlib ./configure --host --build=x86_64-linux-gnu --prefix=/python

make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="arm-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-linux-gnueabi- CROSS_COMPILE_TARGET=yes HOSTARCH=x86_64-linux-gnu BUILDARCH=x86_64-linux-gnu

make install HOSTPYTHON=./hostpython BLDSHARED="arm-linux-gnueabi-gcc -shared" CROSS_COMPILE=arm-linux-gnueabi- CROSS_COMPILE_TARGET=yes prefix=~/Python-2.7.2/_install

有几点需要注意。

  1. 执行第一个命令时,如果--host设置为arm-linux,命令不会执行,告诉我应该使用'--host'进行交叉编译。这就是为什么我没有将它设置为任何东西。
  2. 当运行第二行时,我得到

configure: WARNING: Cache variable ac_cv_host contains a newline. Failed to configure _ctypes module

Python build finished, but the necessary bits to build these modules were not found: _curses _curses_panel _dbm
_gdbm _hashlib _sqlite3
_ssl bz2 ossaudiodev readline zlib To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules: _tkinter

我在运行第三行时遇到了类似的错误,但我猜这是因为上面的命令不起作用。

我正在尝试看看是否有人可以帮助我修复它。

最佳答案

QEMU下原生编译比交叉编译要容易得多。

从您喜欢的任何项目中解压一个 arm chroot,例如arch linux arm、raspbian 等

您已经获得了用于 arm 的二进制 python,但是如果您真的想自己编译:

下载 qemu-user-static(例如 debian 包),解压它。

将单个静态二进制文件安装到您的 arm chroot 的根目录中。

在 proc 中为 binfmt 添加魔法十六进制。 Debian 说明, Gentoo , genric , List of magic hex sequences .以下是我的设置:

mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register
export QEMU_CPU=arm926

可选地,根据需要,mount --bind/tmp、/proc、/sys。

享受你的虚拟 ARM 吧!

关于python - 为 ARM 交叉编译 Python 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20863045/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com