如何让一个复杂的非 Yocto 基于 makefile 的项目在 Yocto 层中进行交叉编译?

时间:2021-03-17 19:57:08

标签: yocto

接下来是
How do I strip and objcopy a built .so file in the Yocto bitbake compile step?
这又引出了大量的背景信息。

正如在上一个问题中提到的,我正在寻求构建 OCA,我有 作为一个非 Yocto 基于 makefile 的项目,在 Yocto 中。该项目构建 在 Yocto 之外,甚至在 Yocto 中,都非常复杂。问题是它 不是针对我的目标进行交叉编译,即 aarch64 armv8-a。它正在建设 成功,但对于我的主机,即 x86-64。然后 Yocto 明智地 拒绝打包,说“无法识别输入的格式 文件”。
我将 makefile 中的编译标志更改为 -march=armv8-a,但出现错误 “cc1plus:错误:'-march=' 开关的错误值('armv8-a'),这似乎是 意味着我不能使用主机安装的 gcc 进行交叉编译,而是使用一个 需要交叉编译器。我之前自定义添加了两个附加层,一个 样本 helloworld 和 mDNS(有关大量背景信息,请参阅前面的问题),以及 它们都可以很好地交叉编译,所以我知道 Yocto 基本上是为做到这一点而设置的。 使交叉编译发生的方法是什么?我需要做很多吗 对我的项目的 makefile 系统的普遍更改?它可能从来没有 设计时考虑到了 Yocto。

我正在研究这个:“yocto 中的交叉编译库配方”:
cross-compile library recipe in yocto
其中似乎有一些相关信息。编辑:这只是我以前见过的标准东西;没有关于如何调用交叉编译而不是主机的 gcc。

编辑:我更新的食谱,添加了 FILES_${PN} 并更改为 oe_runmake。

DESCRIPTION = "OCA"
PRIORITY = "optional"
SECTION = "protocols"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://oca-1.2.7"
S = "${WORKDIR}/oca-1.2.7/Src"
# Need to override S because BitBake expects the source to be in a dir called
#  oca-1.2.7 in the work dir, but it's actually additionally under Src/.
# Need a do_compile, since OCA has a makefile with a non-standard name,
# makefileOCA. Also needs non-standard flags, -f and linuxRelease.
do_compile() {
export CAP_HOME="${WORKDIR}/oca-1.2.7"
oe_runmake -f makefileOCA linuxRelease
}
do_install() {
    install -d ${D}${libdir}
    cp ../Obj/linuxApp/Release/OcaProtoController.so ${D}${libdir}/OcaProtoController.so
    chmod 0755 ${D}${libdir}/OcaProtoController.so
}

FILES_${PN} += "${libdir}/OcaProtoController.so"

编辑:我找到了一些信息:
https://www.yoctoproject.org/docs/1.8.1/adt-manual/adt-manual.html
https://www.yoctoproject.org/docs/1.8.1/adt-manual/adt-manual.html#setting-up-the-cross-development-environment
我把makeOCA.inc中CC和LD的设置注释掉了。

我执行了从 build-wayland 中删除 tmp 文件夹的清理操作 构建目录,并执行“bitbake -c cleansstate oca”。然后我做了“time bitbake oca”。
现在看起来它正在使用交叉编译器。
我现在得到的第一个错误是:
~/Yocto/imx-yocto-bsp/build-wayland/tmp/work/aarch64-poky-linux/oca/1.2.7-r0/oca-1.2.7/Obj/linuxApp/Release/OcaAgentProxies.a
aarch64-poky-linux-ld: 找不到 crus: 没有那个文件或目录

所以这是下一个问题:Can you tell me what "crus" means in "LDFLAGS = crus $@"?

0 个答案:

没有答案
相关问题