【问题标题】:Error when cross compiling Python for ARM为 ARM 交叉编译 Python 时出错
【发布时间】:2014-01-18 17:25:37
【问题描述】:

我正在尝试为 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. 运行第二行时,我得到 ​​li>

配置:警告:缓存变量 ac_cv_host 包含换行符。 _ctypes 模块配置失败

Python 构建完成,但构建这些模块的必要位 没有找到: _curses _curses_panel _dbm
_gdbm _hashlib _sqlite3
_ssl bz2 ossaudiodev readline zlib 要找到必要的位,请查看 在 setup.py 中的 detect_modules() 中获取模块名称。

未能构建这些模块: _tkinter

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

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

【问题讨论】:

  • 您使用的是什么嵌入式 Linux 发行版?如果 Python 版本不重要,你可以选择Buildroot。它提供 Python 3.3。
  • 我把它作为一个练习,CCing for busy-box
  • 无论如何我都不是这方面的专家,但上次我不得不在 ARM(对于 QNX 操作系统)上进行交叉编译时,需要指定 --target 和 --host 的 ./configure 步骤, 我想。如果指定--target=arm-linux 和--host=arm-linux,--host 错误会消失吗?
  • 在我看来,ARM 编译器没有找到编译这些扩展模块(_curses、_ssl、bz2 等)所需的头文件。或者找不到库......这些不是编译器的一部分;所以在任何情况下,您都需要从源代码为 ARM 构建所有这些库(并告诉 python 构建在哪里找到它们)或配置 python 以跳过这些模块。
  • 如果我建议稍微回溯一下,在运行的 ARM 系统中本地编译比交叉编译更容易。为此,我喜欢在 QEMU 中构建 ARM 软件。这是一个快速入门指南。 xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way

标签: python python-3.x arm cross-compiling


【解决方案1】:

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

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

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

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

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

在 proc 中将魔法十六进制添加到 binfmt。 DebianGentoogenricList 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,视需要而定。

享受你的虚拟手臂!

【讨论】:

    【解决方案2】:

    我遇到了同样的错误,只是忽略了它并继续执行建议的程序 http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html

    它与 hello_world 程序一起工作。您还可以从 _install/lib/Python2.7/ 文件夹运行 testall.py 文件。 你也可以参考 http://whatschrisdoing.com/blog/talks/PyConTalk2012.pdf

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2012-02-11
      • 2019-05-21
      • 2011-07-24
      • 2014-12-05
      相关资源
      最近更新 更多