Petalinux - 多源文件应用程序

问题描述

我对 Petalinux 2020.2 版本非常陌生,我正在尝试使用 C 模板在我的项目中创建一个简单的应用程序。

使用以下命令创建 helloworld-app 后:

petalinux-create -t apps --template c --name helloworld-app

启用默认应用程序并成功构建后,我尝试通过在 helloworld-app/files 下创建一个名为 Ethernet 的新目录来添加一些功能,其中包含 2 个文件Etherent.cEthernet.h

最后,我将Ethernet.o 对象添加到为模块自动生成的 Makefile 内的列表中,为了简单起见,我还添加了一个 VPATH。

不幸的是构建失败,实际上 bitbake 告诉我没有指定对象 Ethernet.o 的规则。

  1. 如何修改 makefile 以便编译这个简单的代码?
  2. 我可以编辑 .bb 文件吗?我不想这样做,因为那样我就必须指定每个 src 文件...

感谢您的支持! 以太网.c:

#include "Ethernet.h"
//some C code

helloworld-app.c:

#include <stdio.h>
#include "Ethernet/Ethernet.h"

//some C code

生成文件:

APP = helloworld-app

VPATH=Ethernet

# Add any other object files to this list below
APP_OBJS = helloworld-app.o Ethernet.o

all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CC) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS)
clean:
    rm -f $(APP) *.o

下面我包含了 petalinux-build -c helloworld-app 命令的输出:

enter image description here

解决方法

一个简单的解决方案,但如果文件数量增加,真的很麻烦,就是简单地将源文件的路径添加到 .bb 文件中的变量 SRC_URI 中。我将在没有公认答案的情况下留下这个问题,等待更可持续的解决方案。 谢谢大家!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...