【问题标题】:Petalinux - Multiple Source File applicationPetalinux - 多源文件应用程序
【发布时间】:2021-06-15 22:46:43
【问题描述】:

我对 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 命令的输出:

【问题讨论】:

  • 我猜Ethernet.c 源(和头)文件应该在其他目录中?
  • 您是否尝试将对象设置为Ethernet/Ethernet.o
  • 我也尝试过使用Ethernet/Ethernet.o,结果是一样的。
  • Ethernet目录是否在本示例项目的目录下?
  • Ethernet/ 与 helloworld-app.c 处于同一级别

标签: c yocto xilinx petalinux


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-05-14
    • 2020-05-13
    • 2019-03-02
    • 1970-01-01
    • 2019-11-05
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    相关资源
    最近更新 更多