【问题标题】:cmake based bitbake recipe : sysroot missing?基于 cmake 的 bitbake 配方:缺少 sysroot?
【发布时间】:2018-01-03 21:48:41
【问题描述】:

我觉得我一定是做错了什么。我创建了一个基于 cmake 项目的食谱。使用创建的工具链 yocto 编译项目就像运行 cmake 然后 make 一样简单,但使用配方编译失败:

SUMMARY = "Opendnp3 is the de facto reference implementation of IEEE-1815 (DNP3)"
DESCRIPTION = "Opendnp3 is a portable, scalable, and rigorously tested implementation of the DNP3 (www.dnp.org) protocol stack written in C++11. The library is designed for high-performance applications like many concurrent TCP sessions or huge device simulations. It also embeds very nicely on Linux."
HOMEPAGE = "https://www.automatak.com/opendnp3"
SECTION = "libs"
DEPENDS = "asio"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://NOTICE;md5=9788d3abe6c9401d72fdb3717de33e6a"
SRCREV = "e00ff31b837821064e5208c15866a9d46f8777b1"
SRC_URI = "git://github.com/automatak/dnp3;branch=2.0.x"
S = "${WORKDIR}/git"
inherit cmake
EXTRA_OECMAKE += ""

问题是我认为用于 g++ 的 CXXFLAGS 似乎与工具链环境定义的 CXXFLAGS 不一致。主要是缺少 --sysroot 并且 g++ 无法找到标准 c++ 头文件(例如:cstdint)。

我通过简单地删除 -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake 从 cmake.bbclas 覆盖 do_configure 来部分解决了这个问题。事实上,CXXFLAGS 由 toolchain.cmake 定义为:

 -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a8  --sysroot=/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0=/usr/src/debug/dnp3/2.2.0-r0 -fdebug-prefix-map=/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0/recipe-sysroot-native= -fdebug-prefix-map=/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0/recipe-sysroot=  -fvisibility-inlines-hidden  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a8  --sysroot=/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0/recipe-sysroot

所以 sysroot 被定义(实际上是两次)为:

/home/star/moxa-build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/dnp3/2.2.0-r0/recipe-sysroot

但最终不会出现在 cmake 生成的 Makefile 中,所以我猜 toolchain.cmake 中的某些东西会使项目的 cmake 配置变南。

原来这是项目本身的 cmake 问题。在包含的 .cmake 配置文件之一中,C 和 CXX 标志之间存在愉快的混淆。我将向维护者提交拉取请求。 SDK(直接包含在 CXX 命令中)和 bitbake 对 CXXFLAGS 的处理方式不同,这解释了为什么它可以与 SDK 一起使用(但仍然不太清楚为什么在没有 toolchain.cmake 的情况下它可以工作)。

谢谢。

【问题讨论】:

  • 您可以在 bitbake 食谱时发布错误吗?您是否尝试过不使用 EXTRA_OECMAKE 行?
  • 当然。配方编译日志为here。删除 EXTRA_OECMAKE += "" 行时的结果相同
  • 我会检查错误“致命错误:cstdint:没有这样的文件或目录”。有人建议您需要将 gcc-multilib 添加到您的图像中。 lists.yoctoproject.org/pipermail/yocto/2014-September/…
  • 谢谢。这当然值得一试,但在 Ubuntu 构建主机上安装 gcc-multilib 并没有解决它。它确实使用 yocto 的工具链和标准 cmake 构建流程工作,所以我认为它与构建主机无关,但更可能与配方有关。难道bitbake使用了自己的cmake实现?
  • 我可能没有正确解释。我的意思是将gcc-multilib 添加到 yocto 图像中。

标签: c++ cmake bitbake openembedded


【解决方案1】:

--sysrootCXXFLAGS 中丢失,因为 yocto 将它填充到 CXX 变量本身中。请注意,除了 sysroots 目录 yocto 将有一个 environment-setup-XXX 文件,您应该获取该文件。这就是所有 sysroot 内容的来源。

【讨论】:

  • 谢谢。当我获取 yocto 工具链(在这种情况下为 environment-setup-cortexa8hf-neon-poky-linux-gnueabi )提供的脚本时,CXX 被定义为 arm -poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/opt/poky/2.3/sysroots/cortexa8hf-neon-poky-linux -gnueabi 并调用主机的 cmakemake 与该环境顺利进行。我假设通过配方使用相同的环境,但 cmake 和 make 的实现可能不同。
  • @Louis:我不知道您指的是哪个“cmake 实现”。 AFAIK 在/opt/poky 下没有单独的make。为什么需要一个?
  • 我指的是罗斯伯顿的帖子(见下文)。我的理解是bitbake不使用主机上安装的cmake
  • @Louis:很可能。我已经使用 Yocto 一个星期了,所以我最近也不得不弄清楚这些事情。我的独特印象是他们真的很喜欢重新发明轮子,但记录重新发明的轮子并不是一个优先事项。
  • 这里也一样(使用 Yocto 已经一周了,尽管我在 2 年前进行了一次培训)!但是在获取脚本后检查我使用的 cmake 时,我发现我实际上使用的是 Yocto 的 cmake。
猜你喜欢
  • 2016-07-11
  • 2021-07-14
  • 2020-03-12
  • 2020-07-14
  • 2022-11-11
  • 2021-02-14
  • 2023-03-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多