【问题标题】:How should I configure BitBake to cross compile my python module?我应该如何配置 BitBake 来交叉编译我的 python 模块?
【发布时间】:2016-12-02 08:08:31
【问题描述】:

我继承了一个基于 Open Embedded / Yocto 的项目,我需要为其修改操作系统映像。我想添加一个新的 python 模块 - pycrypto。在我进行更改之前,项目构建得很好。

我为 pycrypto 添加了以下 BitBake 配方:

DESCRIPTION = "Python crypto"   
SECTION = "devel/python"        
LICENSE = "PD"
SRC_URI = "https://pypi.python.org/packages/source/p/pycrypto/pycrypto-${PV}.tar.gz"
SRC_URI[md5sum] = "55a61a054aa66812daf5161a0d5d7eda"
SRC_URI[sha256sum] = "f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c"
LIC_FILES_CHKSUM = "file://README;md5=453a552a607fd82384e25db312340e9a"
S = "${WORKDIR}/pycrypto-${PV}"
inherit setuptools

作为 python-crypto_2.6.1.bb.

然后我在我的主要操作系统映像配方中使用它:

PYTHON_INSTALL = " \
  python-ctypes python-subprocess python-threading python-json \
  python-pyopenssl python-audio python-bsddb python-codecs python-compile python-compiler python-compression python-core python-crypt python-curses python-datetime python-db python-debugger python-dev python-difflib python-distutils python-doctest python-elementtree python-email python-fcntl python-gdbm python-hotshot python-html python-idle python-image python-io python-lang python-logging python-mailbox python-math python-mime python-mmap python-multiprocessing python-netclient python-netserver python-numbers python-pickle python-pkgutil python-pprint python-profile python-pydoc python-re python-readline python-resource python-robotparser python-shell python-smtpd python-sqlite3 python-sqlite3-tests python-stringold python-syslog python-terminal python-tests python-textutils python-tkinter python-unittest python-unixadmin python-xml python-xmlrpc python-zlib python-modules python-pyserial python-misc python-mysql python-crypto\
 "

当构建执行 (bitbake my-image) 时,检索 pycrypto 的源代码似乎一切正常。然而,编译后,configure 尝试运行交叉编译的程序——这不起作用(它是为不同的架构构建的)并停止 bitbake 创建我的图像。

这是日志文件:

DEBUG: Executing shell function do_compile
running build
running build_py
running build_ext
running build_configure
checking for gcc... arm-poky-linux-gnueabi-gcc  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 --sysroot=/media/parallels/build/tmp/sysroots/overo
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/media/parallels/build/tmp/work/cortexa8hf-vfp-neon-poky-linux-gnueabi/python-crypto/2.6.1-r0/pycrypto-2.6.1':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Traceback (most recent call last):
  File "setup.py", line 456, in <module>
    core.setup(**kw)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 251, in run
    self.run_command(cmd_name)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/media/parallels/build/tmp/sysroots/x86_64-linux/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 278, in run
    raise RuntimeError("autoconf error")
RuntimeError: autoconf error
ERROR: python setup.py build_ext execution failed.
WARNING: exit code 1 from a shell command.
ERROR: Function failed: do_compile (log file is located at /media/parallels/build/tmp/work/cortexa8hf-vfp-neon-poky-linux-gnueabi/python-crypto/2.6.1-r0/temp/log.do_compile.6553)

我正在从 x64 主机构建并针对 ARM 处理器。

日志文件中的建议似乎是合理的——“如果您打算交叉编译,请使用 `--host'。” - 唯一的问题是在哪里我应该使用--host?

此外,对现有项目源的搜索显示没有使用--host 的其他实例,这有点令人不安,而且这一切都是为 ARM 构建的,所以也许这条消息让我误入歧途。

任何人都可以帮助配置 BitBake/automake/whatever-part-of-the-Open-Embedded-toolchain,这样一旦我的模块被交叉编译,它就不会尝试在我的主机上执行它(错误的架构)?

谢谢!

【问题讨论】:

    标签: python cross-compiling distutils bitbake openembedded


    【解决方案1】:

    layers.openembedded.org 是你的朋友:http://git.yoctoproject.org/cgit/cgit.cgi/meta-security/tree/recipes-devtools/python/python-pycrypto_2.6.1.bb?h=master

    这需要审查并最好转移到 meta-python,但它应该可以工作。具体来说,我看到它包含自动工具,然后为您执行交叉编译魔法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-27
      • 2021-03-03
      • 1970-01-01
      • 2022-07-04
      • 2021-07-08
      • 2017-12-15
      • 1970-01-01
      • 2011-03-28
      相关资源
      最近更新 更多