【发布时间】: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