简体   繁体   English

我应该如何配置BitBake来交叉编译我的python模块?

[英]How should I configure BitBake to cross compile my python module?

I have inherited an Open Embedded / Yocto based project for which I need to amend the OS image. 我继承了一个基于Open Embedded / Yocto的项目,因此需要修改OS映像。 I would like to add a new python module - pycrypto. 我想添加一个新的python模块-pycrypto。 The project builds just fine before I make changes. 在进行更改之前,该项目的构建就很好。

I have added the following BitBake recipe for 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

as python-crypto_2.6.1.bb. 作为python-crypto_2.6.1.bb。

I then use this in my main OS image recipe: 然后,在我的主要OS映像配方中使用它:

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\
 "

When the build executes ( bitbake my-image ), everything seems to go fine retrieving the sources for pycrypto. 当构建执行时( bitbake my-image ),检索pycrypto的源似乎一切正常。 However after compilation, configure attempts to run the cross compiled program - which doesn't work (it's built for a different architecture) and stops bitbake creating my image. 但是,在编译之后,请配置尝试运行交叉编译程序的程序-该程序不起作用(它是针对另一种体系结构构建的),并且停止bitbake创建我的映像。

Here's the logfile: 这是日志文件:

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)

I'm building from an x64 host and targeting an ARM processor. 我正在从x64主机构建,并针对ARM处理器。

The advice in the logfile seems reasonable - "If you meant to cross compile, use `--host'." 日志文件中的建议似乎是合理的-“如果要交叉编译,请使用'--host'。” - the only problem is where do I use --host? -唯一的问题是我在哪里使用--host?

Also, it's a bit disconcerting that a search of the existing project sources reveal no other instances of --host being used and it all builds for ARM just fine so maybe this message is leading me astray. 同样,有点令人不安的是,对现有项目源的搜索没有发现--host其他实例被使用,并且所有这些都为ARM构建而已,所以此消息可能使我误入歧途。

Can anyone help with configuring BitBake/automake/whatever-part-of-the-Open-Embedded-toolchain so that once my module has been cross compiled it doesn't then try to execute it on my host machine (wrong architecture)? 任何人都可以帮助配置BitBake / automake /任何部分的Open-Embedded-toolchain,以便一旦对我的模块进行交叉编译后,就不再尝试在主机上执行它(错误的体系结构)?

Thanks! 谢谢!

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

This needs to be reviewed and ideally moved to meta-python, but it should work. 这需要进行审查,理想情况下应移至meta-python,但它应该可以工作。 Specifically I see that it includes autotools which then does the cross-compilation magic for you. 具体来说,我看到它包含自动工具,然后可以为您完成交叉编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM